Hello,
I’ve got a little problem using my lilypad arduino.
I want to read/print out values from the sensor that i’ve connected to my arduino, with the arduino duemilanove this works fine. But in case I substitute the duemilanove by the lilypad (and change the board/serial) the values that are printed out are very strange. I’ve tried to change the baud, but i still get values like ‘???’ ‘A7#’ etc.
Is an extra line of code needed to read out values from the lilypad, according the serial port?
using: arduino - 0016 with OS x
am i a newbie: YES ;D
my code:
int sensorPin = 0; // select the input pin for the sensor
int tiltPin1 = 13; // select the pin for the actuators
int tiltPin2 = 12;
int tiltPin3 = 11;
int tiltPin4 = 10;
int tiltPin5 = 9;
int sensorValue = 0; // variable to store the value coming from the sensor
//timer
int clock = 998;
int min = 27;
int sec = 0;
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(tiltPin1, OUTPUT);
pinMode(tiltPin2, OUTPUT);
pinMode(tiltPin3, OUTPUT);
pinMode(tiltPin4, OUTPUT);
pinMode(tiltPin5, OUTPUT);
Serial.begin(9600);
}
void loop() {
delay(clock);
sec = sec + 1;
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// stop the program for milliseconds:
delay(sensorValue);
//cyclus voor houding 1
//tiltmotors aanzetten
if (sensorValue > 750 && sensorValue < 800 && sec < 10)
{
digitalWrite(tiltPin1, HIGH);
digitalWrite(tiltPin2, HIGH);
digitalWrite(tiltPin3, HIGH);
digitalWrite(tiltPin4, HIGH);
digitalWrite(tiltPin5, HIGH);
}
//tiltmotors na bepaalde tijd uitzetten
else if (sensorValue > 750 && sensorValue < 800 && sec > 10)
{
digitalWrite(tiltPin1, LOW);
digitalWrite(tiltPin2, LOW);
}
//uitprinten van sensorwaarde en tijd
Serial.println(sensorValue);
Serial.println(sec);
//regelaar voor minuten en secondes
if (sec > 59) {
sec = 0;
min = min + 1;
}
}