I’m new to Arduino and facing some minor challenges. I am using a code previously written for Version 1.03, but the updated Version is 1.87. Is the older code compatible with the new version?
hrazz7:
...facing some minor challenges...
By providing no description of those challenges you have made it impossible to answer.
hrazz7:
I’m new to Arduino and facing some minor challenges. I am using a code previously written for Version 1.03, but the updated Version is 1.87. Is the older code compatible with the new version?
Don't you think it might be useful to see the code you're talking about?
Anyway why not just try compiling it and see what V1.8.7 tells you?
Steve
hrazz7:
Is the older code compatible with the new version?
Very often, it is.
In "Preferences..." set "Compiler warnings:" to "ALL".
Click on the "Verify" button (the circle with the check mark on the top-left of your sketch window). Look at the warning and error messages to see if anything has gone wrong. Fix the first error or warning. Go back and Verify again. Repeat until all errors and warnings are fixed.
If you are new try not to start off by using some code you found somewhere, which I’m guessing this is .
Do some simple projects , write your own stuff .
johnwasser:
Repeat until all errors and warnings are fixed.
Hmm, are you looking for someone to fix the warnings in e.g. the eeprom and softwareserial libraries ![]()
Here is the code. The program isn't running properly. The right led continually blinks.
// Program for integrating brake lights and turn signals into bike handlebars.
int ledB1 = 5, ledG1 = 6, ledR1 = 3, ledB2 = 10, ledG2 = 11, ledR2 = 9;
int lButton = 2, rButton = 4, lButtonState = 0, rButtonState = 0;
int brakeTime = 4000;
int turnTime = 400, turnCount = 8;
int checkCount = 0, limit = 2;
int wait = 20, longWait = 40, shortWait = 20, lightMax = 255;
int off = 255, on = 0;
int upperBound = 140, lowerBound = 60;
void setup()
{
pinMode(ledB1, OUTPUT);
pinMode(ledG1, OUTPUT);
pinMode(ledR1, OUTPUT);
pinMode(ledB2, OUTPUT);
pinMode(ledG2, OUTPUT);
pinMode(ledR2, OUTPUT);
pinMode(lButton, INPUT);
pinMode(rButton, INPUT);
}
void loop()
{
randColor();
}
void check()
{
lButtonState = digitalRead(lButton);
rButtonState = digitalRead(rButton);
if(lButtonState == HIGH || rButtonState == HIGH)
{
if(lButtonState == HIGH && rButtonState == HIGH)
{
brake();
}
else if(lButtonState == HIGH)
{
lTurn();
}
else
{
rTurn();
}
}
}
void updateCheck()
{
checkCount++;
if(checkCount > limit)
{
checkCount = 0;
check();
}
}
void randColor()
{
// red, green fade in
for(int i = 190; i < lightMax; i++)
{
updateCheck();
if(i > lowerBound && i < 255)
{
wait = longWait;
}
else
{
wait = shortWait;
}
analogWrite(ledB2, off);
analogWrite(ledG2, off - i);
analogWrite(ledR2, on);
analogWrite(ledB1, off);
analogWrite(ledG1, off - i);
analogWrite(ledR1, on);
delay(wait);
}
// red fade out, green
for(int i = 0; i < lightMax; i++)
{
updateCheck();
if(i > 0 && i < upperBound)
{
wait = longWait;
}
else
{
wait = shortWait;
}
analogWrite(ledB2, off);
analogWrite(ledG2, on);
analogWrite(ledR2, on + i);
analogWrite(ledB1, off);
analogWrite(ledG1, on);
analogWrite(ledR1, on + i);
delay(wait);
}
// green, blue fade in
for(int i = 0; i < lightMax; i++)
{
updateCheck();
if(i > lowerBound && i < upperBound)
{
wait = longWait;
}
else
{
wait = shortWait;
}
analogWrite(ledB2, off - i);
analogWrite(ledG2, on);
analogWrite(ledR2, off);
analogWrite(ledB1, off - i);
analogWrite(ledG1, on);
analogWrite(ledR1, off);
delay(wait);
}
// green fade out, blue
for(int i = 0; i < lightMax; i++)
{
updateCheck();
if(i > lowerBound && i < upperBound)
{
wait = longWait;
}
else
{
wait = shortWait;
}
analogWrite(ledB2, on);
analogWrite(ledG2, on + i);
analogWrite(ledR2, off);
analogWrite(ledB1, on);
analogWrite(ledG1, on + i);
analogWrite(ledR1, off);
delay(wait);
}
// blue, red fade in
for(int i = 0; i < lightMax; i++)
{
updateCheck();
if(i > lowerBound && i < upperBound)
{
wait = longWait;
}
else
{
wait = shortWait;
}
analogWrite(ledB2, on);
analogWrite(ledG2, off);
analogWrite(ledR2, off - i);
analogWrite(ledB1, on);
analogWrite(ledG1, off);
analogWrite(ledR1, off - i);
delay(wait);
}
// blue fade out, red
for(int i = 0; i < 120; i++)
{
updateCheck();
if(i > lowerBound && i < upperBound)
{
wait = longWait;
}
else
{
wait = shortWait;
}
analogWrite(ledB2, on + i);
analogWrite(ledG2, off);
analogWrite(ledR2, on);
analogWrite(ledB1, on + i);
analogWrite(ledG1, off);
analogWrite(ledR1, on);
delay(wait);
}
}
void brake()
{
red();
delay(brakeTime);
}
void lTurn()
{
for(int i = 0; i < turnCount; i++)
{
lRed();
delay(turnTime);
allOff();
delay(turnTime);
}
}
void rTurn()
{
for(int i = 0; i < turnCount; i++)
{
rRed();
delay(turnTime);
allOff();
delay(turnTime);
}
}
void lRed()
{
allOff();
digitalWrite(ledG1, HIGH);
digitalWrite(ledR1, LOW);
digitalWrite(ledB1, HIGH);
}
void rRed()
{
allOff();
digitalWrite(ledG2, HIGH);
digitalWrite(ledR2, LOW);
digitalWrite(ledB2, HIGH);
}
void red()
{
allOff();
digitalWrite(ledG2, HIGH);
digitalWrite(ledR2, LOW);
digitalWrite(ledB2, HIGH);
digitalWrite(ledG1, HIGH);
digitalWrite(ledR1, LOW);
digitalWrite(ledB1, HIGH);
}
void allOff()
{
digitalWrite(ledG1, HIGH);
digitalWrite(ledR1, HIGH);
digitalWrite(ledB1, HIGH);
digitalWrite(ledG2, HIGH);
digitalWrite(ledR2, HIGH);
digitalWrite(ledB2, HIGH);
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
sterretje:
Hmm, are you looking for someone to fix the warnings in e.g. the eeprom and softwareserial libraries
Well, the EEPROM library is now warning-free but there is still one in SoftwareSerial.
hrazz7:
Here is the code.
There's nothing in that code that is specific to old IDE versions so I doubt your problem is caused by the IDE version. You could check to be sure by installing Arduino IDE 1.0.3 and giving it a try:
hrazz7:
The program isn't running properly. The right led continually blinks.
Please provide a schematic of your circuit.
hrazz7:
The program isn't running properly. The right led continually blinks.
Are you sure it's the program and not the hardware?