Go Down

Topic: Using LilyPad Arduino, but cannot upload code.. (Read 431 times) previous topic - next topic

HunterB97

Hi, my name is Hunter and I am somewhat new to Arduino. I have already created a project using Arduino Uno, but I want to transfer it to LilyPad. But it will not upload and says that it is not in sync. Can anyone help me please??

//Set the temperature pin input float temperature;
int temperaturePin = A0;

//Set temperature variable
float temperature;

//For serial communication set debug to true, for faster code set debug to false
boolean debug = true;

//Set time and cm for distance sensing
long duration, cm;

//Set pins for trig and echo
int buzzer = 8,trig = 10, echo = 9;

void setup()
{
if (debug) {
Serial.begin(9600);
}

pinMode(trig, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(echo, INPUT);
}

void loop() {

temperature = (getVoltage(temperaturePin) + 0.5) * 100;

if (debug) {
Serial.print("Temperature: ");
Serial.println(temperature);
}

/* Give a short LOW pulse beforehand to ensure a clean HIGH pulse: */
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(5);
digitalWrite(trig, LOW);

duration = pulseIn(echo, HIGH);

//temp. compensated distance
cm = microsecondsToCentimeters(duration, temperature);

//distance without temp.
int old_way_cm = duration/58.2;

controlBuzzer(cm);

if (debug) {

Serial.print("Tempature compensated distance: ");
Serial.print(cm);
Serial.println(" cm");

Serial.print("Distance :");
Serial.println(old_way_cm);


Serial.print("Tempature: ");
Serial.println(temperature);

Serial.print("Duration: ");
Serial.println(duration);
}

delay(50);

}

float getVoltage(int pin)
{
//Converting from 0 to 1024 to 0 to 5v
return (analogRead(pin) * .004882814);
}


long microsecondsToCentimeters(long microseconds, long temp)
{
/*Multiplying the speed of sound through a certain temperature of
air by the //length of time it takes to reach the object and
back, divided by two */
return ((microseconds * (331.3 + 0.606 * temp)) / 2) / 10000;
}

void controlBuzzer(long distance)
{
if (distance <=10000 && distance >= 91){
Serial.print(distance);
Serial.println(" cm");
noTone(buzzer);
}
else if (distance <= 91 && distance >= 61){
Serial.print(distance);
Serial.println(" cm");
tone(buzzer, 100);
delay(300);
noTone(buzzer);
}
else if (distance <= 61 && distance >= 30){
Serial.print(distance);
Serial.println(" cm");
tone(buzzer, 200);
delay(300);
noTone(buzzer);
}
else if (distance <= 30 && distance >= 1){
Serial.print(distance);
Serial.println(" cm");
tone(buzzer, 300);
delay(300);
noTone(buzzer);
}
else {
Serial.println("Out of range");
digitalWrite(buzzer, LOW);
}

}

Sketch uses 7,172 bytes (23%) of program storage space. Maximum is 30,720 bytes.
Global variables use 341 bytes (16%) of dynamic memory, leaving 1,707 bytes for local variables. Maximum is 2,048 bytes.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0

dmjlambert

Try selecting the board "Uno" in the IDE tools, board menu.   

allanv

I have the same problem - with the same messages.  My code compiles, so I know it isn't a code problem.  I have tried all combinations of  three versions of the software, three computers, and three cables/lilypads.  I only see Com1 and Com3 as choices.  One time, I did get a third port to show up, but it still wouldn't upload using it.  When I tried another cable, the third port choice disappeared.

I can make the software work with an Arduino/Uno board.
I have been able to upload to the lilypad before.

codlink

Stop hijacking threads and start your own.  The error in OP is a generalized error which could be solved with a number of different possible solutions.  Look in the device manager with the board plugged in and see if its listed.
//LiNK

HunterB97

Well it doesn't recognize the board itself, just the port. It will tell me when the Uno is plugged in but not the LilyPad. Could it be the cord I'm using? And what's weird is that it worked fine when I switched my two LilyPads out. It uploaded and everything and now it says the exact same thing and the TX light is on. I googled what it meant when the light is on, but none of the solutions worked.

HunterB97

This project is very important to me because I am trying to help the blind "see" if you will. I use a HC-SR04 to detect objects within 3ft, and it will buzz, warning them that something is in the way. I am switching to LilyPad because I will be able to sew it onto a hat or a shirt. That way it isn't so bulky and annoying to carry. Also, I am trying to code a vibration motor to replace the buzzer for the blind that are deaf too.

Go Up