I have made a software that converts black and white picture into binary data. The purpose is to send each row of this binary data to the Arduino that will then ON/OFF the 16 solenoid valves. Currently i am using 16Leds with 74HC595 shift registers(No.02) to simulate the things. I am using Visualbasic to send the Data through the serial port. The problem is i do not know how to collect the data byte by byte or bit by bit by the Arduino... I know how the shiftout function works... i know a little about serial.read functionality.
My software can convert between binary to decimal and Hexadecimal.
The following is what i want to do:
Step-1: in the following binary data, my VB software will split the first row into two bytes. Send the first byte (00000000) to Arduino and then the second byte (00000000) to Arduino.
0000000000000000
0000000111000000
Step-2: The Arduino recieve the data from the serial port in two Variables.
Step-3: The Arduino send the byte data to the two shift registers using Shiftout function.
Step-4: On the shiftout basis the LED will ON/OFF.
The process will then repeat to the second row of mentioned binary data i.e.(11000000) and (00000001)
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
The above code read bytes...but how can it read bits 0 or 1?
Thanks in advance.
MY SOFTWARE GENERATED OUTPUT FROM PICTURE:BINARY DATA
0000000000000000
0000000111000000
0000001111000000
0000111101111000
0000111111111000
0000000000000000
0000111111110000
0011111111111100
0000001111100000
0000001111100000
0000001111100000
0000111111111000
0000011111110000
0000111111111000
0011111111111110
0011111111111110
DECIMAL REPRESENTATION
0 0
1 192
3 192
15 120
15 248
0 0
15 240
63 252
3 224
3 224
3 224
15 248
7 240
15 248
63 254
63 254
HEXADECIMAL REPRESENTATION
0x00 0x00
0x1 0xC0
0x3 0xC0
0xF 0x78
0xF 0xF8
0x00 0x00
0xF 0xF0
0x3F 0xFC
0x3 0xE0
0x3 0xE0
0x3 0xE0
0xF 0xF8
0x7 0xF0
0xF 0xF8
0x3F 0xFE
0x3F 0xFE