Project tutorial

Arduino Inputs Outputs on PC

VB6 app to connect Arduino Uno ports to Windows PC

  • 6,973 views
  • 3 comments
  • 9 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

Arduino PC Monitor

Project tutorial by zakrzu

  • 39,251 views
  • 20 comments
  • 47 respects

Frequency Counter for PC

Project tutorial by moty

  • 15,744 views
  • 0 comments
  • 25 respects

Use a PC Fan as a Sensor

by Daniel Porrey

  • 58,021 views
  • 24 comments
  • 113 respects

Frequency Counter for Android

Project tutorial by moty

  • 4,137 views
  • 3 comments
  • 11 respects

Arduino To Excel Communication

by Mahamudul Karim Khondaker

  • 28,412 views
  • 14 comments
  • 58 respects

Version 2.0 Advanced Attendance System (Without Ethernet)

Project tutorial by Team GadgetProgrammers

  • 24,592 views
  • 47 comments
  • 82 respects
Add projectSign up / Login