Hi,
I need help getting started with my first bit of Arduino code.
I have a Basic Stamp device that generates 20 consecutive bytes of RS-232 data. It then goes and processes another set and then repeats the 20 byte data stream.
I would like to use one of the Chinese Pro Micro Leonardo Arduino devices that has the built in USB port. I have it working on the bench and I can upload and talk to it. That works.
I have been reading the pages here and I fear until I actually start writing my own code, I will just continue to be confused.
I now have my Basic Stamp generating a recirculating 20 byte serial string. There is a nice amount of time between each 20 byte transmission. The baud rate is 38400. I have a proper RS232 Receiver connected to the RXD pin on my Pro Micro Leonardo and I can see the TTL data flying in on the Arduino pin with my scope.
** Here is what I would like to do…
I would like to have a program that reads the incoming serial and stores it in variables in the Arduino.
I would then like to send the decimal or binary value of some or all of the selected bytes to the monitor and have it formatted like:
Variable00 = 256 "
Variable01 = 145
Variable02 = 127
Or perhaps:
Variable00 = 11111111
Variable01 = 01111111
Etc.
Once I have mastered this, I can then learn how to select certain values from given variables to operate a relay, LED or perform some other function.
Here is what I understand…
During Void Setup:
Serial.begin(9600) // set baud rate for Monitor
Serial1.begin(38400) // set baudrate or incoming built in serial port
byte DataString[20] \ set an array to hold 20 bytes of data
During Void Loop:
Serial1.available(==>20) // part of an if statement to get the processing started
Serial.print("Variable 01 is: "); //print some ascii to the monitor so I know what I am seeing
Serial.print(DataString.Variable01); //Print the variable to the serial monitor
Keep doing the above with other variables.
Of course I need to obey the syntax of Arduino and I am beginning to understand that. I am just hoping that someone here will take me under their wing and help me get started.
Greg