Hi, if anyone has 5 mins please can you help me,
I am helping my son on a school project we are making a game for an Easter fair and i need some pointers on programming the arduino.
I have an arduino setup with a button input (10) and an H-bridge on 2 output pins (11,12) controlling a std dc motor i also am using pin 13 as an LED
this is what i want to do:-
push the button and run the motor for 1000ms (advance), I also want to flash the led during the motor running,
Push the button again and now run the motor for 3000ms(rotate) and again flash the LED, it would be great to have a slower flash
finally if the button was initially pressed i need to reverse the motor for 1000ms (Reverse) but only if there is no other activity for 10000ms
I can write code to run the h-bridge to flash led's and do timing but i cant seem to tie it all together.
I need to use some sort of flag something like this:
Press1 Advance, set flag and flash led, start 10000 timer
Press2 only if flag set Rotate flash led and reset 10000 timer leave flag set
if flag not set and counter expired reverse for 250ms then reset flag again flash led same speed at press 1
is this the correct sort of thinking?
how do i use flags? or whatever they are called
how can i flash the led's as I am using the delay(250) to run the motor the whole program pauses; is there a better way
Finally if a button is pressed during a motor run it must be ignored, and not cached.
Is this possible? and can anyone give me some pointers, I am so much better at hardware than software and I am regretting saying i could sort this. oops!!
thanks any help would be really appreciated.
joejet