First off, I am not sure about support in these forums for BASIC Stamps, but I need to interface one to the Arduino. I am having trouble, though. I am trying to get the Arduino to read an analog value, convert it to digital, then send the result over a serial line to the BS2e (Basic Stamp 2e). The BS2e then stores the result in a variable, and displays it in a debug terminal (aka "serial monitor" according to the Arduino software). Here's the Arduino code:
//int txPin = 7;
int micPin = 0;
int val = 0;
void setup() {
Serial.begin(1200); // opens serial port, sets data rate to 9600 bps
//pinMode(Tx_pin, OUTPUT);
}
void loop()
{
val = analogRead(micPin);
Serial.print(val);
//digitalWrite(txPin, val);
delay(200);
}
Ignore the commented out parts (with the "//").
...And here's the PBASIC code (again, ignore the commented out stuff with a " ' ")
' {$STAMP BS2e}
' {$PBASIC 2.5}
value VAR Word(3)
'Tx PIN 0
Rx PIN 1
Baud CON 1200
DO
'value = 0
SERIN Rx, Baud, [value]
'IF value > 0 THEN
DEBUG HOME, DEC value
'ENDIF
LOOP
Maybe someone has experience with BASIC...? Thanks!