Wondered if anyone could help me. I have the code below but cant get it to do what i want!
I basically want it so that when i push the button it stays in the first part of the loop with the LED flashing on and off for a set amount of time. Obviously as its a momentary switch it only does the first loop once as the button goes low straight away again.
You've got an arduino or similar configured with a push button on a digital pin, and a LED connected to one of the PWM pins so you can test it ?
Then start by writing a sketch to which uses analogWrite() to write a value of 50 to the LED pin.
When you've got that far, then in the loop, write a message using Serial.print() if the button is held in and another message if the button is not being held in.
Then start thinking how you'd increment a counter when the button is held in ( myCounter++ ) and how you'd decrement the counter during the period the button is released (myCounter--). Then maybe, try to apply that to the analogWrite() statement.
Ask for help if you get stuck at a specific point.