This document describes a sensor test for a CoasterBot robot created by Black Dog Robotics for a MAKE Robot build challenge in 2010. It tests 4 Sharp digital infrared sensors and 1 Maxbotix sonar sensor by reading their pin values in the Arduino loop and printing the sensor readings to serial output.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100%(1)100% found this document useful (1 vote)
813 views
CoasterBot Sensors Test
This document describes a sensor test for a CoasterBot robot created by Black Dog Robotics for a MAKE Robot build challenge in 2010. It tests 4 Sharp digital infrared sensors and 1 Maxbotix sonar sensor by reading their pin values in the Arduino loop and printing the sensor readings to serial output.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
/*
CoasterBot Sensor test
March-May 2010 for MAKE Robot build challenge
Brian Smith Black Dog Robotics
Test Coasterbot sensors
4 x Sharp Digital IR 1 x Maxbotix sonar */
// set pin numbers:
#define LED_PIN 13// the number of the LED pin #define LF_IR 2// left front IR #define RF_IR 3// right front IR #define LR_IR 4// left rear IR #define RR_IR 5// right rear IR #define SONAR 0 void setup() { // initialize the LED pin as an output: pinMode(LED_PIN, OUTPUT); // digital inputs pinMode(RF_IR, INPUT); pinMode(LF_IR, INPUT); pinMode(RR_IR, INPUT); pinMode(LR_IR, INPUT); // initialize serial communications at 9600 bps: Serial.begin(9600); // flash ready digitalWrite(LED_PIN, HIGH); delay(1000); digitalWrite(LED_PIN, LOW); } // // // void loop() { int rawSonar =analogRead(SONAR); // note - this conversion is approximate! // maxbotix returns 0.01V/inch starting at 6" from front of senso // also seems to float a bit, might be Arduino A2D or sensor // need to look at output voltage for a stable distance to verify // but this will get me close anyway. float convertedSonar = (float)rawSonar * 0.49; Serial.print("Sonar "); Serial.print(rawSonar); Serial.print("/"); Serial.print(convertedSonar); Serial.print(" in "); Serial.print(" RF "); Serial.print(digitalRead(RF_IR) == HIGH ?"Clear" :"Blocked"); Serial.print(" LF "); Serial.print(digitalRead(LF_IR) == HIGH ?"Clear" :"Blocked"); Serial.print(" RR "); Serial.print(digitalRead(RR_IR) == HIGH ?"Clear" :"Blocked"); Serial.print(" LR "); Serial.print(digitalRead(LR_IR) == HIGH ?"Clear" :"Blocked"); Serial.println(""); delay(1000); }