Project tutorial

Arduino Inputs Outputs on PC

VB6 app to connect Arduino Uno ports to Windows PC

  • 1,798 views
  • 0 comments
  • 6 respects

Components and supplies

Apps and online services

About this project

Using PC to connect to Arduino Uno. Included Visual Basic 6 code. The VB6 may need an ActiveX file downloaded from Microsoft. The VB app connects to the Arduino via the COM PORT that the USB drive created and connects the Arduino IDE, when the VB app is running you cannot program the Arduino. You need to enter to the VB app the port number in the way it is done with the IDE. The app displays 4 analogue inputs A0-A3, 6 digital inputs D2-D7 and 6 digital outputs D8-D13

The VB app and code can be downloaded from my website: http://www.moty22.co.uk/usbio.php

Code

arduino to PCArduino
/*
 * IO
 * Created: 12/08/2017 23:34:47
 *  Author: moty22.co.uk
*/

unsigned char inByte=0, outByte=0;         //

// the setup function runs once when you press reset or power the board
void setup() {
    // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
    // initialize outputs 8-13 inputs 2-7 analogue A0-A3
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);          //
  
}

// the loop function runs over and over again forever
void loop() {
  unsigned char i;
  
   if (Serial.available() > 0) {
          // read the incoming byte:
      inByte = Serial.read();
      
      if(inByte < 128)
      {
        PORTB = inByte; //update digital outputs 8-13
      }
      if(inByte == 128) //128 = a request for update
      {
        Serial.write(lowByte(analogRead(A0)));  //send low byte of 10 bits analogue read
        Serial.write(highByte(analogRead(A0))); //send high byte of 10 bits analogue read
        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)));
          //read the 6 digital inputs 2-7 and put them in a byte
        for(i=0;i<6;i++){
        bitWrite(outByte, i, digitalRead(i+2)); 
        }
        Serial.write(outByte);
     }
   }
}

Schematics

pinout
Arduino uno r3 pinout aipvovj3ix

Comments

Similar projects you might like

HOW PIR SENSOR WORK

Project tutorial by DIY Partners

  • 2,130 views
  • 6 comments
  • 20 respects

Arduino Uno-Based, Easy-to-Build Pet Feeder

Project tutorial by edr1924

  • 1,551 views
  • 2 comments
  • 16 respects

4-Stroke Digital Clock With Arduino

Project tutorial by LAGSILVA

  • 7,280 views
  • 8 comments
  • 30 respects

"Living Art" Arduino-Controlled Desk Lamp

Project tutorial by Modustrial Maker

  • 1,288 views
  • 0 comments
  • 4 respects

Dead Bug Valentine

Project tutorial by wrightmac

  • 1,014 views
  • 0 comments
  • 7 respects
Add projectSign up / Login