0% found this document useful (0 votes)
21 views2 pages

Arduino Code Ball

The document discusses connecting an Arduino to an H-bridge to control a fan, and using a VL53L0X laser sensor module to detect distances. It defines pins for the fan motor control and includes libraries for the sensor. In setup it initializes serial, the motor pins, and the sensor. The main loop runs the fan motor continuously, prints distance readings from the sensor, and controls the fan speed based on values received via serial.

Uploaded by

IONUT BABEI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Arduino Code Ball

The document discusses connecting an Arduino to an H-bridge to control a fan, and using a VL53L0X laser sensor module to detect distances. It defines pins for the fan motor control and includes libraries for the sensor. In setup it initializes serial, the motor pins, and the sensor. The main loop runs the fan motor continuously, prints distance readings from the sensor, and controls the fan speed based on values received via serial.

Uploaded by

IONUT BABEI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

//fan blower pinout arduino to H-bridge

#define ena1 3

#define in1 4

#define in2 5

#include <Wire.h>

#include <VL53L0X.h>

VL53L0X sensor;

void setup() {

Serial.begin(9600);

//fan- H-bridge

pinMode(ena1,OUTPUT);

pinMode(in1, OUTPUT);

pinMode(in2, OUTPUT);

//distance detection lidar (laser sensor)

Wire.begin();

sensor.init();sensor.setTimeout(500);

sensor.startContinuous(10);}

void loop() {

//fan

digitalWrite(in1,LOW);

digitalWrite(in2,HIGH);

//sensor VL53IO

Serial.println(sensor.readRangeContinuousMillimeters());

if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT");}

//readingdata fromLabview via serial monitor

if(Serial.available()){

int a=Serial.parseInt();

if(Serial.read()==char(13)) {

int pwmvalue = map(a, -255, 255, 0, 255);

if (pwmvalue < 0){

pwmvalue=0;
}

analogWrite(ena1,pwmvalue);

You might also like