Project tutorial

Arduino Inputs Outputs on PC

VB6 app to connect Arduino Uno ports to Windows PC

  • 2,491 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

CPU and RAM Usage Monitor

Project showcase by thesahilsaluja

  • 1,359 views
  • 10 comments
  • 8 respects

AWS - Arduino Weather Station

Project tutorial by GilettaStefano

  • 5,729 views
  • 11 comments
  • 20 respects

Arduino Sunflower: An Electronic Sun-Dancer

Project tutorial by SURYATEJA

  • 2,990 views
  • 2 comments
  • 10 respects

Backpack Alarm

Project tutorial by Tomi Chen

  • 2,632 views
  • 12 comments
  • 28 respects

Arduino Based Security System

Project tutorial by Abishek Bhalaaji

  • 1,452 views
  • 5 comments
  • 8 respects

Hiking Tracker

Project tutorial by Shahariar

  • 5,178 views
  • 15 comments
  • 37 respects
Add projectSign up / Login