go_away

Author Topic: $50 Robot Digital Input  (Read 532 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?

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
642 Views
Last post August 02, 2009, 03:17:55 AM
by SmAsH
7 Replies
777 Views
Last post July 13, 2010, 09:32:28 PM
by Choco_liger
4 Replies
1442 Views
Last post September 05, 2010, 06:25:54 PM
by moltrex84
0 Replies
1131 Views
Last post March 21, 2011, 10:15:25 AM
by arrrrgon


Get Your Ad Here