So at my school we are preapering for a competition. They asked me to do the technical side of it. And I accepted... I was thinking of using an arduino as a usb device for the buttons. I am going to use the serial port for this. But I can't think of a way to do it in the way I want. I want to recieve the button presses fair and well. But I also want to control the lights for the buttons, from my computer. I am using Serial.printLn()
to send the serial data to the computer. But how can I send serial data to the arduino without delaying other things (What happens when someone presses a button while I am sending a command?)? Thanks in advance!
1 Answer 1
The nastiest part in what you describe is likely to be the debouncing on the button, rather than the serial communication.
One easy way out is to use some form of bounceless implementation, like an optical coupler. Another is to use HW debouncing, like the MAX 6816 family.
Then you can use a loop where you alternate between serial communications and checks for the status of the buttons.
Or you can rely on interrupts for the buttons, but it's more complex and might be overkill.
-
I can try to debounce the button on the computer. I am also writing the code that will be used for the competition...utkumaden– utkumaden2015年11月02日 20:15:31 +00:00Commented Nov 2, 2015 at 20:15
-
The thing is the school is sourcing the parts. I am surprised they even sourced arduinos for the physics lab.utkumaden– utkumaden2015年11月02日 20:25:44 +00:00Commented Nov 2, 2015 at 20:25
I was thinking of using an arduino as a usb device for the buttons.
- what do you mean here? Later you talk about sending serial data to the PC. These are different things.Serial.readLine()
it will halt until it gets an\n