Suresh
Published © CERN-OHL

Car Dashboard

My idea is to create safe driving by reducing the Vehicle Collision.

IntermediateShowcase (no instructions)1 hour2,773
Car Dashboard

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Software apps and online services

Cayenne
myDevices Cayenne

Story

Read more

Code

Code

C/C++
#define CAYENNE_PRINT Serial  
#include <CayenneEthernet.h>
#include <SPI.h>
#include <Ethernet.h>
#define trigPin 8
#define echoPin 9


char token[] = "Token";
#define VIRTUAL_PIN V0
void setup()
{
  
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Cayenne.begin(token);
}

void loop()
{
  Cayenne.run();
}
CAYENNE_OUT(VIRTUAL_PIN)
{
   long duration, distance;
   digitalWrite(trigPin, LOW);
   delayMicroseconds(2);
   digitalWrite(trigPin, HIGH);
   delayMicroseconds(10);
   digitalWrite(trigPin, LOW);

      duration = pulseIn(echoPin, HIGH);

      distance = (duration/2) / 29.1;

   Cayenne.virtualWrite(VIRTUAL_PIN, distance);
}

Credits

Suresh
18 projects • 20 followers
IoT Developer
Contact

Comments

Please log in or sign up to comment.