Arduino Sketches

Discuss all kinds of software here including apps, games and operating systems. You can also share software guides and receive help for your software in this section.
User avatar
SKYLINE1000000
Artist
Artist
Posts: 57
Joined: Tue Apr 23, 2013 4:26 pm

Arduino Sketches

Fri Apr 03, 2015 10:12 pm

I've been working on a robot using a ping sensor which has 4 pins. Power, Gnd, Trigger and echo.

This small piece of coding I did is to see if my new ping sensor is working but it seems my PC isn't detecting
the board with the ping sensor powered to the 3.3volt pin. I tried increasing the voltage on the main power source but it
didn't ended well with my board...

Code: Select all

int echo = 2; //Pin Number
int ping = 4; //Pin Number
float distCM = 0;

void setup(){
  pinMode(ping, OUTPUT);
  pinMode(echo, INPUT);
  Serial.begin(9600);
}

void loop(){
  digitalWrite(ping, LOW);
  delayMicroseconds(2);
  digitalWrite(ping, HIGH);
  delayMicroseconds(5);
  digitalWrite(ping, LOW);
  
  distCM = pulseIn(echo, HIGH);
  
  Serial.print(distCM);
  delay(5000);
}

Return to “Software Centre”

Who is online

Users browsing this forum: No registered users and 1 guest