Society of Robots - Robot Forum
Software => Software => Topic started by: arrrrgon on March 21, 2011, 10:30:17 AM
-
I would like to add a Bump Sensor to my $50 robot. I've already received tips on how to add my new 3 pin headers to my $50 robot board, but now I'm wondering how to get the input from the switch into my code. How do I go about reading the switch input in my code?
Thanks for any help.
-
I think I found my answer.
cbi(DDRA, PA1);//set A1 as input pin
//if sensor output is 0, do something
if(bit_is_clear(PINA, 1))
take_over_world();
Where PA1 is whichever I/O pin I decide to use? Do I need to declare the digital pin in the header file, or are all unused pins automatically set to accept digital input?