Tag: arduino
HC-SR04 Ping distance sensor
14/11/2013
Working on a small mockup that should read sensors, [do some stuff here] and send it to clients website/server..
Using a sensor like the HC-SRo4 Ping distanse sensor to send a signal to the RasBotPi when someone walks inside the range is a nice idea for the moment. Although for the project I am working on, this is not the best idea 🙂
But Arduino and a breadboard gives you the power to fool arround and see if it fits your needs.
On twitter I found out about this guy: Hazim Bitar.
His website is http://www.techbitar.com and you can follow him on twitter too.  He created an app that reads Arduino sensors using bluetooth. Got me thinking about the final project and how we can overcome the distance without the needs of cable (or to setup a complete wifi network) on the “moving” location.
Anyway, this sensor came from china (dx.com). There are lots of sketches to find if you do a  google. The one I post here works too. Dunno exact where I found it..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
/* HC-SR04 Ping distance sensor: VCC to arduino 5v GND to arduino GND Echo to Arduino pin 7 Trig to Arduino pin 8 This sketch originates from Virtualmix: http://goo.gl/kJ8Gl Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html And modified further by ScottC here: http://arduinobasics.blogspot.com/ on 10 Nov 2012. */ #define echoPin 7 // Echo Pin #define trigPin 8 // Trigger Pin #define LEDPin 13 // Onboard LED int maximumRange = 200; // Maximum range needed int minimumRange = 0; // Minimum range needed long duration, distance; // Duration used to calculate distance void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(LEDPin, OUTPUT); // Use LED indicator (if required) } void loop() { /* The following trigPin/echoPin cycle is used to determine the distance of the nearest object by bouncing soundwaves off of it. */ 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/58.2; 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 { /* Send the distance to the computer using Serial protocol, and turn LED OFF to indicate successful reading. */ Serial.println(distance); digitalWrite(LEDPin, LOW); } //Delay 50ms before next reading. delay(50); } |
Share the post "HC-SR04 Ping distance sensor"
Gertboard ATmega IO vs. Arduino Pins
24/08/2013
The printing on the Gertboard indicated the port and pin numbers internal to the Atmega microcontroller…
However this is normally hidden from the user by the Arduino’s “wiring” library and rather than refer to (e.g.) Port B, bit 5, you’d normally refer to “pin 15″.
The mapping is fairly straightforward, but to help you connect wires to pins on the Gertboard, here is a handy table to let you see what the connections are:
See source:
https://projects.drogon.net/raspberry-pi/gertboard/gertboard-atmega-io-vs-arduino-pins/
Share the post "Gertboard ATmega IO vs. Arduino Pins"
Setup Arduino IDE serial monitor on the Raspberry Pi
24/08/2013
The Arduino IDE does not understand names such as /dev/ttyAMA0.
One suggestion is to
1 |
sudo ln -s /dev/ttyAMA0 /dev/ttyUSB9 |
and restart the Arduino IDE.
This creates an alias to /dev/ttyAMA0 which the IDE may understand.
Source:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=42&t=28908
Share the post "Setup Arduino IDE serial monitor on the Raspberry Pi"