Controlling Arduino I/O lines from a PC
Arduino I/O lines give incredible prospects to controlling different outside gadgets. Furthermore, they are genuinely simple to program through the Arduino IDE.
Controlling Arduino I/O lines from a PC
Be that as it may, there are times when outside gadgets should be controlled from a PC, and afterward Arduino turns into a great alternative as a halfway connection between an outer gadget and a PC.
Since the Arduino can without much of a stretch interface with a PC utilizing a USB link and trade information utilizing a sequential port, it is sufficient to compose a PC program that sends orders to control some I/O line, and a sketch for Arduino that would acknowledge these orders and killed on or the comparing line. A PC program written in Visual Basic 6 can be downloaded here (an ActiveX document might be needed for VB6).
The VB application associates with the Arduino through a COM port that imitates USB. At the point when the VB application is running, you can't program the Arduino. You need to enter the port number in the VB application, much the same as in the Arduino IDE. The application shows 4 simple data sources A0-A3, 6 advanced data sources D2-D7 and 6 computerized yields D8-D13.
The code (sketch) for the Arduino :
unsigned char inByte=0, outByte=0; void setup() { Serial.begin(9600); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); }void loop() { unsigned char i; if (Serial.available() > 0) { inByte = Serial.read(); if(inByte < 128) { PORTB = inByte; } if(inByte == 128) { Serial.write(lowByte(analogRead(A0))); Serial.write(highByte(analogRead(A0))); Serial.write(lowByte(analogRead(A1))); Serial.write(highByte(analogRead(A1))); Serial.write(lowByte(analogRead(A2))); Serial.write(highByte(analogRead(A2))); Serial.write(lowByte(analogRead(A3))); Serial.write(highByte(analogRead(A3))); for(i=0;i<6;i++){ bitWrite(outByte, i, digitalRead(i+2)); } Serial.write(outByte); } }}