MAS 863.10 How to make almost everything
MAS 863.10 How to make almost everything
WK 11 | NETWORKING
Monday, December 6, 2010
HOW TO PROGRAM YOUR FABDUINO TO HAVE SERVO’S TALKK AS IN MOVIE:
WRITING SERVO POTENTIOMETER
int readValue=0;
//sender
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
/*
Serial.write (1);
Serial.write (2);
Serial.write (3);
Serial.write (4);
*/
Serial.write(analogRead(0)/4);
delay(25);
/*
Serial.println(analogRead(0));
delay(15);
*/
}
READING SERVO POTENTIOMETER
int readValue=0;
//sender
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
/*
{
int first, secnd, third, fourth;
first = secnd = third = fourth = 0;
while(first != 1 || secnd != 2 || third != 3 || fourth !=4)
{
if(Serial.available() > 0){
first = secnd;
secnd = third;
third = fourth;
fourth = Serial.read();
}
*/
// get incoming byte:
{
if (Serial.available())
{
val = (int)Serial.read();
/*val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
*/
val = map(val, 20, 100, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
}
HOW TO PROGRAM YOUR FABDUINO
MAKEFILE:
1) Select Arduino Board Tools/Board/your arduino version
2)Select Right Serial Port Tools/Serialport/ Usually the top port
3) Put ArduinoISP software on arduino File / Examples / ArduinoISP --> Load onto board
x) Connect Fabuino pins to Arduino:
D13 -> D13
D12 ->D12
D11 -> D11
..
3) open makefile and change ISPPORT from /dev/tty.usbserial-A600etF8
to your arduino serial port number
3)go to terminal and type:
make lilypad_isp
(or for resonator: make lilypad_resonator_isp)
4a) right when led blinks, hold down reset button on fabduino
4)a when asked to "read a", unpress reset button and hit enter, when led blinks hold reset until done
FABDUINO AND SERVO’S