SIMPLE ARDUINO VB NET DATA LOGGER
by computeraidedautomation in Circuits > Electronics
3472 Views, 7 Favorites, 0 Comments
SIMPLE ARDUINO VB NET DATA LOGGER
![1.JPG](/proxy/?url=https://content.instructables.com/F51/03PN/JR6OH3JM/F5103PNJR6OH3JM.jpg&filename=1.JPG)
A simple data logger made with Arduino and VB.NET Express edition
VB Part
![11.JPG](/proxy/?url=https://content.instructables.com/FHK/3R2W/JR6OH3JO/FHK3R2WJR6OH3JO.jpg&filename=11.JPG)
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
Arduino Part
![1111.JPG](/proxy/?url=https://content.instructables.com/FON/U4ZY/JR6OH3JL/FONU4ZYJR6OH3JL.jpg&filename=1111.JPG)
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”);
}
Working..
![Arduino VB.NET Serial Port Data Logging with Ultrasonic Distance Sensor](/proxy/?url=https://content.instructables.com/F89/GZA9/JR6OH3K6/F89GZA9JR6OH3K6.jpg&filename=Arduino VB.NET Serial Port Data Logging with Ultrasonic Distance Sensor)
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