sensorColorpal
masalcido
Posts: 8
in Accessories
I HAVE A PROBLEM WITH THIS SENSOR SOMEONE COULD HELP ME
Comments
Might be a good idea to show what it is hooked up to, how it is hooked up, what kind of problem you are having, and post the code you are using. My psychic powers are a bit low at the moment.
-Phil
#include <SoftwareSerial.h>
SoftwareSerial Color90(2, 3);
/*====================================================
/ Connect ColorPAL SIG signal to Arduino pin 2 and 3
/ Baud Rate = 9600 kbps /
/====================================================*/
void setup() {
Serial.begin(9600);
Color90.begin(4800);
pinMode(2,INPUT);
pinMode(3,INPUT);
digitalWrite(2,HIGH); // Enable the pull-up resistor
digitalWrite(3,HIGH); // Enable the pull-up resistor
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
pinMode(2,INPUT);
pinMode(3,INPUT);
Serial.println("Pass 1");
while( digitalRead(2) != HIGH || digitalRead(3) != HIGH ) {
Serial.println("In the loop");
delay(50);
}
Serial.println("Pass 2");
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
delay(80);
pinMode(2,INPUT);
pinMode(3,OUTPUT);
delay(100);
}
//
void loop() {
char rByte[9];
Color90.begin(4800); Color90.print("= V !"); delay(500); Color90.print("= R !");
Color90.print("= $ m !");
rByte[0] = Color90.read();
if(rByte[0] == '$'){
for(int i=0; i < 9; i++){
rByte = Color90.read();
Serial.print(rByte);
}
Serial.println();
}
delay(500);
}