Skip to content

Instantly share code, notes, and snippets.

#include
#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup() {
Serial.begin(9600);
/*
* created by Rui Santos, http://randomnerdtutorials.com
*
* Complete Guide for Ultrasonic Sensor HC-SR04
*
Ultrasonic sensor Pins:
VCC: +5VDC
Trig : Trigger (INPUT) - Pin11
Echo: Echo (OUTPUT) - Pin 12
GND: GND
/*
* created by Rui Santos, http://randomnerdtutorials.com
*
* Complete Guide for Ultrasonic Sensor HC-SR04
*
Ultrasonic sensor Pins:
VCC: +5VDC
Trig : Trigger (INPUT) - Pin11
Echo: Echo (OUTPUT) - Pin 12
GND: GND
/*
* created by Rui Santos, http://randomnerdtutorials.com
* Temperature Sensor Displayed on 4 Digit 7 segment common anode
* 2013
*/
const int digitPins[4] = {
4,5,6,7}; //4 common anode pins of the display
const int clockPin = 11; //74HC595 Pin 11
const int latchPin = 12; //74HC595 Pin 12
const int dataPin = 13; //74HC595 Pin 14
@ruisantos16
ruisantos16 / gist:5023583
Created February 24, 2013 12:05
Control DC motor with Smartphone via bluetooth
/*
* created by Rui Santos, http://randomnerdtutorials.wordpress.com
* Control DC motor with Smartphone via bluetooth
* 2013
*/
int motorPin1 = 3; // pin 2 on L293D IC
int motorPin2 = 4; // pin 7 on L293D IC
int enablePin = 5; // pin 1 on L293D IC
int state;
int flag=0; //makes sure that the serial only prints once the state
@ruisantos16
ruisantos16 / Control Servo with Visual Basic
Created February 12, 2013 20:47
Control Servo with Visual Basic (Arduino code) visit my website for more information. www.randomnerdtutorials.com
/*
* created by Rui Santos, http://randomnerdtutorials.wordpress.com
* Control a servo motor with Visual Basic
* 2013
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
@ruisantos16
ruisantos16 / Control LED's with a remote control
Last active December 12, 2015 10:28
Control LED's with a remote control, you can see the full project at my website www.randomnerdtutorials.com
/*
* IRremote Library - Copyright 2009 Ken Shirriff
* created by Rui Santos, http://randomnerdtutorials.wordpress.com
* Control LED's with a remote control
* 2013
*/
#include <IRremote.h>
int IR_Recv = 3; //IR Receiver Pin 3
@ruisantos16
ruisantos16 / Ultrasonic Sensor with LED's bar graph and buzzer
Created February 11, 2013 23:54
Ultrasonic Sensor with LED's bar graph and buzzer, you can see the full project at my website http://randomnerdtutorials.wordpress.com
/*
* created by Rui Santos, http://randomnerdtutorials.wordpress.com
* Ultrasonic Sensor with LED's bar graph and buzzer
* 2013
*/
int tonePin = 4; //Tone - Red Jumper
int trigPin = 9; //Trig - violet Jumper
int echoPin = 10; //Echo - yellow Jumper
int clockPin = 11; //IC Pin 11 - white Jumper
int latchPin = 12; //IC Pin 12 - Blue Jumper