Author Topic: $50 Robot Digital Input  (Read 659 times)

0 Members and 1 Guest are viewing this topic.

Offline arrrrgonTopic starter

  • Jr. Member
  • **
  • Posts: 37
  • Helpful? 0
$50 Robot Digital Input
« 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.

Offline arrrrgonTopic starter

  • Jr. Member
  • **
  • Posts: 37
  • Helpful? 0
Re: $50 Robot Digital Input
« Reply #1 on: March 21, 2011, 10:51:37 AM »
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?

 


Get Your Ad Here

data_list