SIMPLE ARDUINO VB NET DATA LOGGER

Introduction: SIMPLE ARDUINO VB NET DATA LOGGER

About: Interested in Computer aided automation things

A simple data logger made with Arduino and VB.NET Express edition

Step 1: VB Part

Create a new windows form application in VB Express

Insert


1 Combo Box (comPort_ComboBox)

2 Button (connect_BTN, clear_BTN for connect & clear)

1 Serial port controller (SerialPort1)

1 Timer (Timer1)

1 Label (Timer_LBL)1 Rich Text Box (RichTextBox1)

Copy and paste VB codes (shown below) thanks to martyn currey
Upload the arduino codes to your arduino (shown below) Connect Arduino Digital IO 13 pin to LED +ve,

Ultrasonic’s Echo Pin to Arduino Digital IO 7 and Ultrasonic’s Trig Pin to Arduino Digital IO 8 Build and Run the VB Program Check the accuracy by placing your hands on Ultrasonic Reader

Step 2: Arduino Part

Connect Arduino Digital IO 13 pin to LED +ve, Ultrasonic’s Echo Pin to Arduino Digital IO 7 and Ultrasonic’s Trig Pin to Arduino Digital IO 8

#define echoPin 7 // Echo Pin

#define trigPin 8 // Trigger Pin

#define loadpin 13 // Trigger Pin

int jij = 0;

int maximumRange = 200; // Maximum range needed

int minimumRange = 0; // Minimum range needed

float duration, distance; // Duration used to calculate distance

void setup() {

Serial.begin(9600); // set serial speed

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(loadpin, OUTPUT); // Use LED indicator (if required)

digitalWrite(loadpin, LOW); //turn off LED

}

void loop()

{

while (Serial.available() == 0); // do nothing if nothing sent

int val = Serial.read() – ‘0’; // deduct ascii value of ‘0’ to find numeric value of sent number

if (val == 1) { // test for command 1 then turn on LED

digitalWrite(loadpin, HIGH); // turn on LED

deflstart();

//jij = 1;

}

else if (val == 0) // test for command 0 then turn off LED

{

digitalWrite(loadpin, LOW); // turn off LED

//jij=2;

deflstop();

}

else // if not one of above command, do nothing

{

//val = val;

}

//Serial.println(val);

Serial.flush(); // clear serial port

jij = 3;

}

void deflstart()

{

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

//Calculate the distance (in cm) based on the speed of sound.

distance = duration/5.81;

if (distance >= maximumRange || distance <= minimumRange){

/* Send a negative number to computer and Turn LED ON

to indicate “out of range” */

Serial.println(“-1”);

//digitalWrite(LEDPin, HIGH);

}

else {

Serial.println(distance);

// digitalWrite(LEDPin, LOW);

}

//Delay 50ms before next reading.

delay(100);

}

void deflstop()

{

//Serial.println(“stop”);

}

Step 3: Working..

Run the program

Select the source (port)

if everything done correct, the distance between the ultrasonic sensor and the object within its range appears in the rich text box


Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    Discussions

    0
    furious84
    furious84

    Question 7 months ago

    hi, sorry but where can i find the vb code?