Project tutorial

Arduino Inputs Outputs on PC © LGPL

VB6 app to connect Arduino Uno ports to Windows PC

  • 997 views
  • 0 comments
  • 4 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

Schematics

pinout
Arduino uno r3 pinout aipvovj3ix

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);
     }
   }
}

Comments

Similar projects you might like

Automation of Railway Models Part 1 - Sensors

Project tutorial by Steve_Massikker

  • 647 views
  • 3 comments
  • 13 respects

Vintage Bench-Top DC Hybrid Voltmeter using Arduino

Project tutorial by Shahariar

  • 195 views
  • 0 comments
  • 6 respects

LittleBot Simple Arduino Robot

Project showcase by Slant Concepts

  • 427 views
  • 0 comments
  • 7 respects

Automatizing Percussion with Solenoids: "The Sound Compass"

Project tutorial by touchmysound

  • 1,571 views
  • 2 comments
  • 6 respects

Arduino Sunflower

Project tutorial by Rick_Findus

  • 936 views
  • 0 comments
  • 4 respects
Add projectSign up / Login