Sensors Board C Code
Explanation
This code uses the O.A.R. Sensor Board. When the sensor detects a black line the processor sets the output port (PORTD) high. When the sensor detects black PORTD it asserted low.
#include <inttypes.h> #include <avr/pgmspace.h> int main(void){ DDRD = 0xf0; // Configuration of port D // f = output, 0 = input PORTD |= (1<<0); // Set pull-up resistor while (1){ // Read PORTD pin 0 if( !(PIND & 0x01) | 0x00 ){ // If sensor sees black PORTD = 0xF0; //Set high nibble of PORTD high } else{ // If sensor sees white PORTD = 0x00; //Set low nibble of PORTD low } } } // END main
page_revision: 10, last_edited: 1209611406|%e %b %Y, %H:%M %Z (%O ago)





