View Single Post
  #3   Spotlight this post!  
Unread 23-02-2004, 21:08
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Banner Sensor Programming Problem

Quote:
Originally Posted by KenWittlief
Im more lost than you are - a digital input should only be able to give a value of 1 or 0

I have no idea how you are getting 256 or all those other values from a single bit pin

try searching your code on the variable names - maybe there is a stray equation someplace that is setting the bit variables to something else?

this is really strange.
the input you he's getting on rc_dig_in01 is actually 0 and 1, but it's being printf'd without being cast to an int - thus, the unsigned char value is being taken along with a second byte of padding, thus 0 + 256 = 256, and 1 + 256 = 257.

2Crisis, when you printf values, make sure you do it like this:

Code:
printf("dig in 1: %d", (int) rc_dig_in01);
make sure you have the banners wired correctly - the blue and brown wires for both sensors should be hooked up to a 20 amp fuse on your fuse panel, and either the white or the black wire (the same color for both sensors) should be hooked up to the SIG pin of the digital input port.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)