Arduino Tutorial Lesson 5 Program Question

For makers who have purchased an Adafruit Starter Pack, get help with the tutorials here!

Moderators: adafruit_support_bill, adafruit

Arduino Tutorial Lesson 5 Program Question

Postby mew211 » Sun Dec 16, 2012 2:55 pm

Hi,

I just did Design Challenge part 3 in Lesson 5 of the Arduino tutorials.
I wrote my own code and it would go through each of the modes fine, but when it got to the wave mode, pressing the button again would not return to the "off" mode.
I tested the code on the site, which of course worked fine.

I noticed that the only difference between the two was that in the wave function I had a delay(500) in my program, while the tutorial had delay(50) in their program.
I changed mine to delay(50) and the code worked fine. Then I changed the code from the tutorial to delay(500) and it had the same problem as mine.

Can anyone explain why this happens? Does the wave function have to run through a certain number of cycles or something? I don't see what in the code would be causing this.
Thanks!
mew211
 
Posts: 1
Joined: Tue Nov 27, 2012 3:20 pm

Re: Arduino Tutorial Lesson 5 Program Question

Postby adafruit_support_bill » Mon Dec 17, 2012 5:52 am

During the delay, you are not checking the button state. With a longer delay you are more likely to miss the button press.
User avatar
adafruit_support_bill
 
Posts: 15916
Joined: Sat Feb 07, 2009 9:11 am


Return to Arduino Starter Pack

Who is online

Users browsing this forum: No registered users and 1 guest

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
Android[6]
 
BeagleBone[24]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]