Arduino: Difference between revisions
(356 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Hardware = | = Hardware = | ||
== [http://arduino.cc/en/Main/ArduinoBoardUno Uno] == | |||
The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. | |||
= Source code = | This means that the Uno can execute 16 million 8 bit instructions per second. | ||
Basic facts: | |||
* It has digital input/output pins and analog inputs but no analog output pins. See [[#PWM.2FAnalog_Output|PWM/Analog output]]. | |||
* Each pin can only handle 40 mA of current. So there is a chance to blow the chip if you directly connect motors to it without a motor controller (That's what people invented H-bridge), not to say about changing current. See also the discussion [http://electronics.stackexchange.com/questions/57238/why-exactly-does-connecting-a-motor-directly-to-an-arduino-damage-it stackexchange] and [http://forum.arduino.cc/index.php/topic,19962.0.html arduino] forums (Google: why we should not direct connect motor to arduino). | |||
== [http://arduino.cc/en/Main/ArduinoBoardDue Due] == | |||
The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU (datasheet). It is the first Arduino board based on a 32-bit ARM core microcontroller. It has 54 digital input/output pins (of which 12 can be used as PWM outputs), 12 analog inputs, 4 UARTs (hardware serial ports), a 84 MHz clock, an USB OTG capable connection, 2 DAC (digital to analog), 2 TWI, a power jack, an SPI header, a JTAG header, a reset button and an erase button. | |||
Since UNO is 8-bit and DUE is 32-bit, there is difference in terms of storage. On the Arduino Uno (and other ATMega based boards) an ''int'' stores a 16-bit (2-byte) value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1). | |||
On the Arduino Due, an ''int'' stores a 32-bit (4-byte) value. This yields a range of -2,147,483,648 to 2,147,483,647 (minimum value of -2^31 and a maximum value of (2^31) - 1). See http://arduino.cc/en/Reference/int and [http://forum.arduino.cc/index.php?topic=182219.0 Discussion] of comparing UNO & Due. | |||
Another interesting point is '''neither of them have floating point support''' (Beaglebone bone and Rasp Pi do have FP). | |||
== Comparison of Boards == | |||
* https://www.sparkfun.com/arduino_guide | |||
* http://arduino.cc/en/Products.Compare | |||
* http://learn.adafruit.com/adafruit-arduino-selection-guide/arduino-comparison-chart | |||
* http://www.tested.com/tech/robots/456466-know-your-arduino-guide-most-common-boards/ | |||
== Memory == | |||
* http://playground.arduino.cc/Learning/Memory | |||
* http://learn.adafruit.com/memories-of-an-arduino/arduino-memories | |||
# Flash memory (program space), is where the Arduino sketch is stored. Flash memory is the same technology used for thumb-drives and SD cards. It is non-volatile, so your program will still be there when the system is powered off. | |||
# SRAM (static random access memory) is where the sketch creates and manipulates variables when it runs. This memory includes 3 kinds of space: '''static data, heap''' and '''stack'''. | |||
# EEPROM is memory space that programmers can use to store long-term information. | |||
== Wio Terminal == | |||
[https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/ Get Started with Wio Terminal] | |||
= Arduino alternatives = | |||
* https://www.makeuseof.com/tag/best-arduino-alternative-microcontrollers/ | |||
** NodeMCU | |||
** Teensy 3 | |||
** MSP430 Launchpad | |||
** STM32 | |||
** PocketBeagle | |||
= [https://www.arduino.cc/en/Main/Software Arduino IDE] = | |||
The serial port is ttyACM0 for UNO, ttyUSB0 for Nano under my Ubuntu. To detect the serial port device, first run | |||
<pre> | |||
ls -t /dev/tty* | |||
</pre> | |||
Then plug in Arduino UNO and run the above command again. See [http://playground.arduino.cc/Interfacing/LinuxTTY playground.arduino.cc]. | |||
== Source code in Github == | |||
https://github.com/arduino/Arduino/tree/master/hardware/arduino/cores/arduino | https://github.com/arduino/Arduino/tree/master/hardware/arduino/cores/arduino | ||
== Install Arduino IDE under Ubuntu == | |||
* http://askubuntu.com/questions/107619/how-do-i-install-the-arduino-ide | |||
* http://blog.markloiseau.com/2012/05/install-arduino-ubuntu/ | |||
Using source code (For some reason, I cannot find ~/.arduino/preference.txt file with this approach) | |||
<pre> | |||
sudo apt-get install arduino-core | |||
sudo apt-get install openjdk-7-jre | |||
# Go to http://arduino.cc/en/main/software to download the latest software | |||
tar xzvf arduino-1.0.5-linux32.tgz | |||
cd arduino-1.0.5 | |||
sudo ./arduino | |||
</pre> | |||
The 2nd [http://playground.arduino.cc/Linux/Ubuntu approach] is (I think it is better since I can find and modify ~/.arduino/preference.txt file). | |||
<pre> | |||
sudo apt-get update && sudo apt-get install arduino arduino-core | |||
</pre> | |||
After Arduino IDE is installed, I can change the font (Line 11 of preference.txt file) from Monospaced DejaVu Sans Mono,plain,12 to something like | |||
<pre> | |||
editor.font=DejaVu Sans Mono,bold,16 | |||
OR | |||
editor.font=Courier New,bold,16 | |||
</pre> | |||
PS. Open AbiWord to check available fonts in Ubuntu OS. | |||
'''Update 6/27/2016''': I download the tar ball from [https://www.arduino.cc/en/Main/Software official website] in order to get the latest version. Running <install.sh> from Arduino 1.6.9 under Ubuntu | |||
* sudo is not needed. Just run <install.sh> | |||
<syntaxhighlight lang='bash'> | |||
$ '/home/brb/binary/arduino-1.6.9/install.sh' | |||
Adding desktop shortcut, menu item and file associations for Arduino IDE... done! | |||
</syntaxhighlight> | |||
* if we open Arduino as a regular user, we cannot write to the serial port. So we need to run '''sudo usermod -a -G dialout <username>''' to fix it. '''Remember to log out and log in again for this change to take effect'''. See https://www.arduino.cc/en/Guide/Linux. | |||
* Not sure if this is necessary: '''sudo chmod a+rw /dev/ttyACM0''' (It seems if I issue it, I don't need to log out & log in) | |||
== Using Arduino IDE as user instead sudo in Ubuntu == | |||
http://www.mycontraption.com/installing-arduino-on-ubuntu-12-10/ | |||
<pre> | |||
brb@brb-P45T-A:~$ ls -lt /dev | more | |||
total 0 | |||
crw-rw-rw- 1 root tty 5, 2 Sep 15 20:07 ptmx | |||
crw-rw-rw- 1 root tty 5, 0 Sep 15 20:06 tty | |||
drwxr-xr-x 2 root root 3820 Sep 15 20:06 char | |||
drwxr-xr-x 4 root root 80 Sep 15 20:06 serial | |||
crw-rw---- 1 root dialout 166, 0 Sep 15 20:06 ttyACM0 | |||
crw-rw---- 1 root dialout 4, 64 Sep 15 19:51 ttyS0 | |||
sudo usermod -a -G dialout yourusename | |||
</pre> | |||
Then log out and log in again. Type 'groups' to see if the current user belongs to dialout group. | |||
No only we don't need to use 'sudo' to run arduino, we can also save a sketch under user's ownership. | |||
The 2nd trick is to make the menu on the Arduino IDE to be visible. Open and edit arduino-1.0.5/arduino file, and then modify the last line so it becomes "java processing.app.Base". What this essentially does is uses the Arduino look and feel instead of the GTK version. | |||
== Arduino Reset Button == | |||
To "reset" the Uno power it down, hold down the reset button, and, while still holding the reset button down, power it up again. This will prevent the existing sketch from running. You can then upload a new sketch. | |||
== ArduBlock - [https://scratch.mit.edu/ Scratch] like interface for Arduino == | |||
ArduBlock is a programming environment designed to make “physical computing with Arduino as easy as drag-and-drop.” Instead of writing code, worrying about syntax, and (mis)placing semicolons, ArduBlock allows you to visually program with an snapped-together list of code blocks. | |||
* http://blog.ardublock.com/engetting-started-ardublockzhardublock/ | |||
* http://sourceforge.net/projects/ardublock/ (source code) | |||
* https://learn.sparkfun.com/tutorials/alternative-arduino-interfaces/ardublock | |||
== Arduino Library == | |||
* [https://blog.arduino.cc/2015/10/26/how-to-write-a-library-for-arduino/ How to write a library] | |||
* https://www.arduino.cc/en/Hacking/Libraries | |||
For example, if we want to try the [http://forum.arduino.cc/index.php?topic=328631.0 pong game] which uses the [https://github.com/smaffer/vgax vgax] library, we can copy the vgax folder and paste it to '''arduino-1.6.5-r5/libraries''' folder (I am using Linux OS). The library will appear under ''Arduino IDE -> File -> Example'' when we launch the IDE next time. | |||
== Arduino Web Editor == | |||
[https://blog.arduino.cc/2016/11/22/the-library-manager-is-now-available-on-the-web-editor/ THE LIBRARY MANAGER IS NOW AVAILABLE ON THE WEB EDITOR!] | |||
= Arduino Simulators = | |||
[https://www.makeuseof.com/arduino-simulators-electronics-projects/ 4 Arduino Simulators You Can Use in Your Electronics Projects] | |||
= C users = | = C users = | ||
Line 10: | Line 135: | ||
* http://code.google.com/p/libarduino/ | * http://code.google.com/p/libarduino/ | ||
* http://www.joakimlinde.se/microcontrollers/arduino/avr/ | * http://www.joakimlinde.se/microcontrollers/arduino/avr/ | ||
= R = | |||
[https://andresrcs.rbind.io/2020/02/09/arduino_microcontroller_r/ Alternatives for retrieving sensor data from Arduino compatible microcontrollers into R] | |||
= Programming using Scratch = | |||
http://s4a.cat/ | |||
Since this will involve uploading a firmware to Arduino, we now can only do programming using S4A. We can go back to use Arduino IDE for programming if we want to discard using S4A. | |||
s4a is available as deb package. | |||
Simple example (button & LED) | |||
# Connect wires according to http://s4a.cat/. I use 330 Ohm resistor. The digital pin I use is 3, not 2. | |||
# '''sudo s4a''' to launch S4A | |||
# Follow the instruction in [http://www.instructables.com/id/A-Gentle-Introduction-to-Arduino-for-Scratch-Users/?ALLSTEPS instructables.com] to try 1. LED blinking and 2. LED and button in S4A. | |||
One problem with this idea is the arduino board needs to be connected to computer all the time. | |||
= Tutorials = | = Tutorials = | ||
* https://www.youtube.com/watch?v=OkSGiko5EE0&list=PLE0C7D8863F6DACCE | |||
* http://www.nunoalves.com/classes/spring_2012_cpe355/ | |||
* [http://learn.adafruit.com/arduino-tips-tricks-and-techniques Arduino Tip, Tricks and Techniques] | |||
* [http://learn.adafruit.com/adafruit-arduino-lesson-5-the-serial-monitor/overview Serial monitor] | |||
* http://tronixstuff.wordpress.com/tutorials/ | * http://tronixstuff.wordpress.com/tutorials/ | ||
* http://startingelectronics.com/beginners/ | |||
* https://www.sparkfun.com/tutorials/57 | |||
* http://www.ladyada.net/learn/arduino/ | |||
* [http://projectsfromtech.blogspot.com/2013/05/stepper-motors-and-arduino-28byj-48.html Stepper motor] See the [https://github.com/arraytools/arduino/tree/master/stepperMotor1 example 1] where the motor turns in two directions and [https://github.com/arraytools/arduino/tree/master/stepperMotor2 example 2] code where the motor turns continuously in one direction. The connection of motor to the arduino is very simple: Just 1. connecting IN1, IN2, IN3, IN4 to pin 8,9,10,11 and 2. connecting GND to GND in arduino and VCC to 5v in arduino. The connection of [http://dx.com/p/dc-5v-28ybj-48-stepper-motor-for-arduino-2-pcs-148819 28BYJ-48 motor] to [http://dx.com/p/uln2003-stepper-motor-driver-module-blue-149605 uln2003] is obvious. See my video on [http://youtu.be/i6gTikvy_dk Youtube]. | |||
[[File:StepperMotor.jpg|100px]] | |||
* Micro servo. See http://magnusglad.wordpress.com/2013/03/13/tested-my-sg90-servo-today/ for an instruction and my video on [http://youtu.be/unzYp4GqU-g Youtube]. | |||
[[File:MicroServo.jpg|100px]] | |||
* Check google to see the difference between dc motor and servo. [https://www.modmypi.com/blog/whats-the-difference-between-dc-servo-stepper-motors This site] explains the difference among dc motor, servo motor and step motor. [https://learn.adafruit.com/all-about-stepper-motors?view=all Adafruit.com] has an article to explain stepper motors. | |||
* [https://www.adafruit.com/products/171 Adafruit motor shield v2]. It can be used to control DC motors, stepper motors and servos. It can drive up to 4 DC motors or 2 stepper motors. | |||
= Arduino IDE, Books, Forums = | |||
== IDE == | |||
* On ubuntu, we need to run arduino using sudo; otherwise, the serial port is greyed out. | |||
* Save/Save As will create a folder and a file with the extension .ino. | |||
* Cheat sheet https://dlnmh9ip6v2uc.cloudfront.net/learn/materials/8/Arduino_Cheat_Sheet.pdf | |||
* For 'Prescaler.h' library, it is not part of arduino IDE. So the way I do is | |||
<pre> | |||
# Create a file 'Prescaler.h' under ~/sketchbook/ | |||
# ln -s /home/brb/sketchbook/Prescaler.h ~/binary/arduino-1.0.5/hardware/arduino/cores/arduino/Prescaler.h | |||
# nano ~/sketchbook/Prescaler.h and change WProgram.h to Arduino.h. | |||
# OK. It is the time to run sketch_05_01_prescale from Arduino IDE > sketchbook > ArduinoNextSteps. | |||
</pre> | |||
See the [http://forum.arduino.cc/index.php?topic=147680.0 post]. | |||
== Books == | |||
* [http://www.simonmonk.org/?page_id=55 Programming Arduino] and [http://www.simonmonk.org/?page_id=370 Programming Arduino Next Steps] by Simon Monk. | |||
* [http://www.amazon.com/Getting-Started-Arduino-Make-Projects/dp/0596155514 Getting Started with Arduino] by Massimo Banzi. | |||
* [http://www.amazon.com/Practical-Arduino-Projects-Hardware-Technology/dp/1430224770/ref=sr_1_1?s=books&ie=UTF8&qid=1314992868&sr=1-1 Practical Arduino] by Jon Oxer and Hugh Blemings. | |||
* [http://www.amazon.com/Exploring-Arduino-Techniques-Engineering-Wizardry/dp/1118549368/ref=pd_cp_b_1 Exploring Arduino: Tools and Techniques for Engineering Wizardry] and [http://exploringarduino.com/ Book's website]. | |||
* [http://www.amazon.com/Arduino-Workshop-Hands-On-Introduction-Projects/dp/1593274483/ref=pd_rhf_cr_s_cp_1_ZGAC?ie=UTF8&refRID=11PTZB1VPKF4DZFH566N Arduino Workshop: A Hands-On Introduction with 65 Projects] | |||
* [http://www.amazon.com/Make-Sensors-Hands-On-Monitoring-Raspberry/dp/1449368107/ref=tmm_pap_title_0 Make: Sensors: A Hands-On Primer for Monitoring the Real World with Arduino and Raspberry Pi] | |||
== Forums == | |||
* [http://arduino.cc/forum/ Arduino forum] and [http://forums.adafruit.com/ Adafruit forum] | |||
* (Blog) [http://blog.makezine.com/arduino Make] and [http://www.instructables.com/technology/arduino/ Instructables]. | |||
* [http://www.freeduino.org/ Freeduino] | |||
* [http://arduino.cc/en/Reference/HomePage Language Reference] | |||
= Processing/Graph = | |||
It is possible to send a byte of data from the Arduino to a personal computer and graph the result. This is called serial communication because the connection appears to both the Arduino and the computer as a serial port, even though it may actually use a USB cable. | |||
* First, download and install [http://www.processing.org/ Processing] software (currently 2.0.3) | |||
* Check out http://arduino.cc/en/Tutorial/Graph for wiring. Very simple. Just one potentiometer and 3 wires (one goes to gnd, 2nd one goes to 5v and the 3rd one connects to A0). | |||
* Check out http://www.dustynrobots.com/news/seeing-sensors-how-to-visualize-and-save-arduino-sensed-data/ for the idea of how to plot the analog data using Processing. It contains 2 steps: 1. Open Arduino IDE ('''sudo''' is necessary if OS is not Windows) and compile/run a code to print byte to serial using Serial.write(). 2. Open Processing ('''sudo''' is necessary if OS is not Windows) and run a code. We shall be able to see a beautiful streaming graph appearing on screen. Both codes are attached below. | |||
Arduino | |||
<pre> | |||
int sensorPin = A0; // analog input pin to hook the sensor to | |||
int sensorValue = 0; // variable to store the value coming from the sensor | |||
void setup() { | |||
Serial.begin(9600); // initialize serial communications | |||
} | |||
void loop() { | |||
sensorValue = analogRead(sensorPin)/4; // read the value from the sensor | |||
Serial.write(sensorValue); // print bytes to serial | |||
delay(10); | |||
} | |||
</pre> | |||
Processing | |||
<pre> | |||
import processing.serial.*; | |||
Serial myPort; // The serial port | |||
float xPos = 0; // horizontal position of the graph | |||
void setup () { | |||
size(800, 600); // window size | |||
// List all the available serial ports | |||
println(Serial.list()); | |||
String portName = Serial.list()[0]; | |||
myPort = new Serial(this, portName, 9600); | |||
background(#EDA430); | |||
} | |||
void draw () { | |||
// nothing happens in draw. It all happens in SerialEvent() | |||
} | |||
void serialEvent (Serial myPort) { | |||
// get the byte: | |||
int inByte = myPort.read(); | |||
// print it: | |||
println(inByte); | |||
float yPos = height - inByte; | |||
// draw the line in a pretty color: | |||
stroke(#A8D9A7); | |||
line(xPos, height, xPos, height - inByte); | |||
// at the edge of the screen, go back to the beginning: | |||
if (xPos >= width) { | |||
xPos = 0; | |||
// clear the screen by resetting the background: | |||
background(#081640); | |||
} | |||
else { | |||
// increment the horizontal position for the next reading: | |||
xPos++; | |||
} | |||
} | |||
</pre> | |||
[[File:ProcessingPotentiometer.png|100px]] | |||
More: | |||
* http://playground.arduino.cc/Interfacing/Processing | |||
== Data Logging == | |||
* [https://plot.ly/ Plotly] and [https://plot.ly/api/ API] | |||
* [https://learn.sparkfun.com/tutorials/internet-datalogging-with-arduino-and-xbee-wifi https://learn.sparkfun.com/tutorials/internet-datalogging-with-arduino-and-xbee-wifi] | |||
* [http://www.open-electronics.org/how-send-data-from-arduino-to-google-docs-spreadsheet/ Google Spreadsheet] | |||
= [http://www.parallax.com/boeshield Robot based on BOE shield for Arduino] = | = [http://www.parallax.com/boeshield Robot based on BOE shield for Arduino] = | ||
Line 18: | Line 286: | ||
My robot is based on 'Shield for Arduino' which means I can use Arduino IDE + [http://learn.parallax.com/ShieldRobot C code style] to write my code instead of using PBASIC programming which is used in [http://www.parallax.com/Store/Robots/AllRobots/tabid/128/ProductID/302/List/0/Default.aspx?SortField=ProductName,ProductName another similar robot]. | My robot is based on 'Shield for Arduino' which means I can use Arduino IDE + [http://learn.parallax.com/ShieldRobot C code style] to write my code instead of using PBASIC programming which is used in [http://www.parallax.com/Store/Robots/AllRobots/tabid/128/ProductID/302/List/0/Default.aspx?SortField=ProductName,ProductName another similar robot]. | ||
== Projects from each chapters == | |||
=== Chapter 3. Activity 2: Re-test the servos === | |||
We can use Pins 11 and 12 instead of 12 and 13. Be sure to adjust your code accordingly. | |||
=== Chapter 4. Activity 2 === | |||
First time we disconnect robot from the computer and let it go (forward, left turn, right turn and back ward). | |||
=== Chapter 5 (Whiskers). Activity 3 or 4 === | |||
See my robot is in action on http://www.youtube.com/watch?v=sjzQI6GHe3w. | |||
[[File:Robot whisker.jpg|100px]] | [[File:Robot whisker.jpg|100px]] | ||
=== Chapter 7 (Infrared headlight). Activity 4 === | |||
Similar to Chapter 5 but IR detectors are used. See the robot in action on | |||
http://www.youtube.com/watch?v=K5pIZ5XcP7Y. | |||
Activity 7: Drop-off detection (Very Cool). | |||
[[File:Robot Infrared.jpg|100px]] | [[File:Robot Infrared.jpg|100px]] | ||
This [http://letsmakerobots.com/node/29634 site] contains some more information to use infrared LED to avoid object by testing on arduino board. | |||
== Using regular IR remote controll == | |||
''The Arduino code provided for this project makes the BOE Shield-Bot recognize Sony IR remote signals only! For example, the BRIGHTSTAR universal remote sold by Parallax is programmed by holding the SET-UP button down until an LED on the remote lights up, then entering the code 605. Different models of remotes may use different codes and configuration methods. Check your remote's docs!'' See the instruction and arduino code in [http://learn.parallax.com/project/ir-remote-controlled-shield-bot/program-shield-bot-and-remote IR Remote Controlled Shield-Bot]. | |||
== Using ping))) with BOEShield == | |||
Information and arduino code from [http://learn.parallax.com/project/shield-bot-roaming-ping Parallax]. I find the code by [http://learn.parallax.com/search/node/ping%29%29%29 searching within parallax.com]. See http://thoughtfix.com/blog/2012/3/25/arduino-boe-shield-ping-and-a-servo.html for arduino code. Some modified code [http://forum.arduino.cc/index.php?topic=148467.15 here]. My recorded video is available on [http://www.youtube.com/watch?feature=player_embedded&v=I1IDGPM96pw Youtube]. | |||
[[File:Robot ping.jpg|100px]] | |||
= Other robots = | = Other robots = | ||
* (Tutorial) http://www.foxytronics.com/learn/robots/how-to-make-your-first-arduino-robot | |||
* http://www.robotshop.com/ | |||
* http://www.robotsimple.com/ | |||
* http://www.ez-robot.com/ including [http://www.youtube.com/watch?v=-rqdtgcnG3A EZ-B Bluetooth Servo Tamiya Bulldozer Robot] | * http://www.ez-robot.com/ including [http://www.youtube.com/watch?v=-rqdtgcnG3A EZ-B Bluetooth Servo Tamiya Bulldozer Robot] | ||
* [http://www.instructables.com/id/Arduino-controlled-Bluetooth-bot/ Arduino controlled Bluetooth-bot] and [http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS this one]. | |||
* (Book) [http://www.apress.com/9781430231837 Arduino Robotics By John-David Warren , Josh Adams , Harald Molle] | |||
* [http://giftguide.makezine.com/robots.html Robot gift guide] from makezine.com. | |||
== Video == | |||
[http://www.ted.com/talks/raffaello_d_andrea_the_astounding_athletic_power_of_quadcopters.html The astounding athletic power of quadcopters] from TED. | |||
== Kit == | |||
* [http://www.makeblock.cc/starter-robot-kit-v2-0-blue-with-electronics/ v2] and [http://www.makeblock.cc/starter-robot-kit-v1-0-gold-with-electronics/ v1] from makeblock. | |||
= Projects = | |||
== Special Projects == | |||
* [https://blog.arduino.cc/2016/08/15/build-an-electric-go-kart-on-a-budget-with-arduino/ Go kart] | |||
* [http://www.instructables.com/id/Arduino-Based-Smart-Glasses-by-a-13-Year-Old-Jorda/?ALLSTEPS Smart Glasses] | |||
* [http://lifehacker.com/this-diy-wireless-keylogger-fits-anywhere-looks-like-a-1739266989 Wireless Keylogger] and the [http://samy.pl/keysweeper/ original post] | |||
* [https://blog.arduino.cc/2015/09/24/yet-another-cool-pong-with-arduino-uno/ Ping pong with Arduino UNO] which makes use of the [https://github.com/smaffer/vgax vgax] library (VGA library for Arduino UNO). The library implement a 120x60px framebuffer. The library also implements an async tone (audio) generation too. As mentioned in the [https://forum.arduino.cc/index.php?topic=328631.0 forum], it is OK to use only one potentiometer and button. The two paddles move in parallel in this case. | |||
* [http://www.makeuseof.com/tag/how-to-recreate-the-classic-pong-game-using-arduino/ How To Recreate The Classic Pong Game Using Arduino] | |||
* [http://lamages.blogspot.com/2012/10/connecting-real-world-to-r-with-arduino.html Connecting the real world to R with an Arduino] | |||
* [https://learn.sparkfun.com/tutorials/ad8232-heart-rate-monitor-hookup-guide/all Heart Rate Monitor]. Select Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328 in Arduino IDE. I need to change the Serial.list()[32] in sketch since the output on processing shows I have /dev/ttyS0 /dev/ttyS1 ... /dev/ttyS31 /dev/ttyUSB0. Processing does not need to or have no way to select the Arduino board on its GUI. | |||
: [[File:HeartRateMonitor2.jpg|100px]] | |||
* [https://blog.arduino.cc/2018/12/28/star-trek-tricorder-style-heart-rate-monitor/ Check your heart rate with this Star Trek-inspired handheld monitor] | |||
* [http://www.instructables.com/id/Geek-at-Heart/?ALLSTEPS This] is a DIY heart rate monitor from instructables.com. | |||
* [http://blog.arduino.cc/2014/07/25/arduino-plays-timberman/ Arduino plays timberman] | |||
* [https://blog.arduino.cc/2016/06/24/arduino-simulator-puts-you-in-the-drivers-seat-of-a-toy-car/ Arduino simulator puts you in the driver’s seat of a toy car] | |||
* Arduino CPU monitor. | |||
** http://www.instructables.com/id/System-Monitor-With-Arduino-and-7-Segment-Display/ Linux Mint was used. | |||
** <strike>http://www.linuxuser.co.uk/tutorials/arduino-cpu-monitor</strike> https://www.gadgetdaily.xyz/arduino-cpu-monitor/ We get real-time CPU data and display it with a series of LEDs. We’ll also look into adjusting the brightness of those LEDs with a potentiometer, and running the app as a background process with Forever.js. | |||
** https://blogs.oracle.com/ksplice/entry/building_a_physical_cpu_load | |||
** http://forum.arduino.cc/index.php?topic=171114.0 (windows) | |||
** http://forum.arduino.cc/index.php?topic=302422.0 (16x2 lcd) | |||
** https://www.raspberrypi.org/forums/viewtopic.php?t=114620&p=784702 Raspberry Pi | |||
** [https://create.arduino.cc/projecthub/thesahilsaluja/cpu-and-ram-usage-monitor-windows-linux-921282 CPU and RAM Usage Monitor (Windows & Linux)] | |||
<ul><ul> | |||
<li>http://www.instructables.com/id/Arduino-CPURAM-usage-monitor-LCD/ (Windows + VB.net). The key is how to send data to the serial port from PC (Windows or Linux). The serial port could be [http://unix.stackexchange.com/questions/117037/how-to-send-data-to-a-serial-port-and-see-any-answer /dev/ttyS0 or /dev/ttyS1 or /dev/ttyACM0] for Linux. [http://www.cyberciti.biz/faq/find-out-linux-serial-ports-with-setserial/ How To Check and Use Serial Ports Under Linux] from cyberciti.biz. You have to plug in an Arduino in order to get the port. See also [[Udoo#minicom|Udoo > Minicom]]. The arduino code is very simple | |||
<syntaxhighlight lang='c'> | |||
#include <LiquidCrystal.h> | |||
//Set's lcd to the Arduino's ports | |||
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |||
void setup() { | |||
lcd.begin(16, 2); | |||
Serial.begin(9600); | |||
} | |||
void loop() { | |||
String content = ""; | |||
char character; | |||
while(Serial.available()) { | |||
character = Serial.read(); | |||
content.concat(character); | |||
} | |||
if (content != "") { | |||
if (content == "`") { | |||
content = ""; | |||
lcd.setCursor(0,1); | |||
} | |||
if (content == "*") { | |||
content = ""; | |||
lcd.setCursor(0,0); | |||
} | |||
Serial.println(content); | |||
lcd.print(content); | |||
} | |||
if (content == "~") { | |||
lcd.clear(); | |||
} | |||
} | |||
</syntaxhighlight> | |||
</li></ul></ul> | |||
* [https://blog.arduino.cc/2016/07/18/lawn-da-vinci-is-an-open-source-remote-controlled-lawn-mower/ Lawn Da Vinci - remote-controlled lawn mower], [https://www.instructables.com/id/Remote-Control-Lawn-Mower/ Remote Control Lawn Mower] | |||
* [http://www.instructables.com/id/impBoot-Remotely-Turn-on-a-Desktop-Computer/ Turn on a remote computer] | |||
== Simple LED == | |||
GND --- wire --- 300 Ohm --- short end of LED --- long end of LED --- wire --- 5v/3.3v. | |||
The 300 Ohm resistor can be replaced by anyone between 100 Ohm and 10K Ohm. | |||
== 7 Segment LED == | |||
* [http://allaboutee.com/2011/01/30/pic18-explorer-board-how-to-make-an-automatic-counter-with-a-7-segment-led/ Design]. Note that for common anode, we need to connect pin 3, 8 to 5V and for common cathode we want to connect pin 3,8 to gnd. | |||
* [http://www.hacktronics.com/Tutorials/arduino-and-7-segment-led.html Arduino example (digits)]. I need to change seven_seg_digit to 1-seven_seg_digit in digitWrite() function since mine has common anode. | |||
* [http://en.wikipedia.org/wiki/Seven-segment_display_character_representations How to represent all alphabet] | |||
[[File:7segmentLED.jpg|100px]] | |||
== LCD Keypad shield == | |||
This Arduino shield includes a 16x2 HD44780 White on Blue LCD module and a 5 push button keypad for menu selection and user interface programming. The shield can be directly used by opening Arduino > Example > CrystalLCD > Autoscroll as long as we have changed the pin numbers (see comments from dx.com); changing the lcd object to the following | |||
<syntaxhighlight lang='c'> | |||
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // instead of lcd(12, 11, 5, 4, 3, 2); | |||
</syntaxhighlight> | |||
Note that there are two versions of shield. | |||
* (Wiki) http://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_%28SKU:_DFR0009%29 It seems only 8 pins are used. So if the shield is placed on a breadboard we can make use the other pins on Arduino. | |||
* (Hello World with timing) Arduino IDE > Examples > LiquidCrystal > HelloWorld. | |||
* (Display buttons/LCD Keypad) http://arduinotronics.blogspot.com/2012/06/lcd-keypad-shield.html. The source code is in [https://github.com/arraytools/arduino/tree/master/LCDKeypad github]. A simpler code http://www.hobbytronics.co.uk/arduino-lcd-keypad-shield works for me. | |||
* (Display barchart) http://www.mathias-wilhelm.de/arduino/shields/dfrobot-lcd-16x2-shield/ I saved the source code in my [https://github.com/arraytools/arduino/tree/master/BarChart github]. | |||
* (Buy from) http://dx.com/p/lcd-keypad-shield-for-arduino-duemilanove-lcd-1602-118059#.UtyCQNdOnoo | |||
* [http://www.mathias-wilhelm.de/arduino/beginner/schritt-6-lcd-displays/ A diagram shows which pins are used or available] | |||
[[File:LcdShieldArduino.jpg|100px]] | |||
== Control DC motors == | |||
* [https://www.sparkfun.com/products/10825 Magician Chassis] | |||
* [https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview Adafruit]'s arduino lesson 13 gives an instruction of controlling the speed of a small DC motor, PN2222 Transistor, 1N4001 diode and 270 Ω Resistor (red, purple, brown stripes). A similar instruction was given by [http://makezine.com/projects/control-a-5v-motor-with-the-arduino/ Make]. | |||
* DC motor reversing from [https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing?view=all Adafruit arduino lesson 15]. It uses a L293D IC, 10 kΩ variable resistor (pot) and Tactile push switch. | |||
* [http://itp.nyu.edu/physcomp/Labs/DCMotorControl DC motor's direction using an H-bridge] from itp.nyu.edu. | |||
* An instruction given by [http://www.jeremyblum.com/2011/01/31/arduino-tutorial-5-motors-and-transistors/ Jeremyblum.com]. | |||
* L298P Motor Shield For Arduino ([https://www.sparkfun.com/products/9815 Ardumoto]) from [http://www.ebay.com/itm/171167538405?_trksid=p2060778.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT ebay] and [http://arduino.cc/en/Main/ArduinoMotorShieldR3 arduino.cc]. Use 3 pins to control each of 2 motors (direction, speed, brake). | |||
[[File:L298P motor shield.jpg|100px]] | |||
* 5V L298N Dual Stepper Motor Driver Controller Board Module from [http://www.ebay.com/itm/111320781130 ebay]. It includes standoff and is very large (~ 2 inch x 2 inch). | |||
* [http://www.instructables.com/id/Use-Arduino-with-TIP120-transistor-to-control-moto/ PC fan motor (brushless)]: using TIP120 transistor to control motors and high power devices. | |||
* [http://themakersworkbench.com/content/tutorial/reading-pc-fan-rpm-arduino Reading pc fan rpm]. The pc fan can be just powered by a 9V battery. I save a copy of the code in [https://github.com/arraytools/arduino/tree/master/motorRPM github]. PS. 9 wires and 3 crocodile clips in addition to 1 PC case fan are needed. | |||
[[File:ArduinoDCmotor.jpg|100px]] | |||
[[File:ArduinoMotorRPM.png|100px]] | |||
=== Bubble blaster === | |||
https://toemat.com/bubble-gun/ | |||
== Using Web to read/write GPIO (it works) == | |||
http://uggettif.blogspot.com/2012/11/controlling-arduino-from-web-page.html | |||
== Using Node/Websocket to create a Web page and control Arduino == | |||
* http://danieldvork.in/arduino-controlled-html5-etch-a-sketch-using-node-js-and-websockets/ | |||
* http://semu.github.io/noduino/ | |||
* http://www.olivierklaver.com/chapter_3.html | |||
== Ethernet Shield == | |||
=== Test Ethernet Shield === | |||
Use sketch_12_01_dhcp from Programming Arduino Next Steps. Or | |||
<syntaxhighlight lang='c'> | |||
// sketch_12_01_dhcp | |||
#include <SPI.h> | |||
#include <Ethernet.h> | |||
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; | |||
void setup() | |||
{ | |||
Serial.begin(9600); | |||
while (!Serial){}; | |||
if (Ethernet.begin(mac)) | |||
{ | |||
Serial.println(Ethernet.localIP()); | |||
} | |||
else | |||
{ | |||
Serial.println("Could not connect to network"); | |||
} | |||
} | |||
void loop() | |||
{ | |||
} | |||
</syntaxhighlight> | |||
Open Serial Monitor. Mine shows 10.42.0.37 when I use ethernet 1 from PC to share the internet connection. | |||
=== Control light from a browser === | |||
* http://hub.flower-platform.com/#/repositories/page/flower-platform-arduino-projects%7Ccontrol-lights-from-web-and-buttons | |||
== [http://www.blynk.cc/ Blynk] - mobile app == | |||
Blynk allows to create an iOs, [https://play.google.com/store/apps/details?id=cc.blynk Android] app for any connected project or product based on Arduino, Raspberry, ESP8266, and other hardware. | |||
[http://www.makeuseof.com/tag/getting-started-blynk-simple-diy-iot-devices/ Getting Started With Blynk: Simple DIY IoT Devices] | |||
== ESP8266 == | |||
[https://www.makeuseof.com/tag/wifi-connected-button-esp8266-tutorial/ How to Make Your Own Wi-Fi Connected Button With ESP8266] | |||
== ESP32 == | |||
[https://www.makeuseof.com/how-to-detect-room-presence/ How to Detect Room Presence and Automate Smart Home Devices With ESP32] | |||
== Arduino with bluetooth == | |||
* JY-MCU Bluetooth for [http://robotosh.blogspot.com/2012/07/arduino-jy-mcu-bluetooth.html Windows/Linux] and [http://42bots.com/tutorials/arduino-uno-and-the-jy-mcu-bluetooth-module-with-softwareserial/ Android]. The JY-MCU is also called [http://mcuoneclipse.com/2013/06/19/using-the-hc-06-bluetooth-module/ HC-06]. | |||
[[File:Bluetooth.jpg|100px]] | |||
It works as the instruction on Windows Vista computer. However on Ubuntu computer (I use my bluetooth dongle obtained from Udoo) I need to | |||
# Make sure the arduino code has been uploaded to arduino uno via USB cable when bluetooth module is not connected to arduino. After the code has been uploaded to arduino, we can connect the bluetooth module to arduino and then power on arduino. | |||
# Don't use Ubuntu default bluetooth utility. Download and install [https://apps.ubuntu.com/cat/applications/precise/blueman/ blueman] (Bluetooth manager) from software center. | |||
# Paired it to jy-mcu (device name is linvor) . Enter pin number 1234. | |||
# Right click on 'linvor' in blueman and click setup. The default option 'serial port' is good so we can click 'forward' button. At this time, the connection should be successful. The screen also shows the device is on /dev/rfcomm0. | |||
# Open Arduino IDE. The IDE does not need to have any code there. Select Tools > board > 'Arduino Uno'. For some reason Arduino IDE 1.0.5 does not find the port /dev/rfcomm0 but Arduino IDE 1.5.7 finds the port. So I use Arduino IDE 1.5.7 to test jy-mcu. | |||
# Open the serial monitor and make sure the baud rate is 9600. Type H to turn on the LED and L to turn off the LED. That's it. | |||
For Android device, it works too by following the author's instruction. | |||
# Download the free [https://play.google.com/store/apps/details?id=es.pymasde.blueterm&hl=en Blueterm] app. P.S. I found from play store that the app [https://play.google.com/store/apps/details?id=mBluetoothSerialController.nomal&hl=en Bluetooth Serial Controller] made by Next Prototypes works well - we can assign commands (in terms ASCII) to different buttons and we can hide buttons. | |||
# Rx on jy-mcu is connected to arduino Pin 2 and Tx is connected to Pin 4. Note that I did not use shift register/resistors between Rx on jy-mcu and Android. | |||
# Open Android > Bluetooth > Setting to connect jy-mcu (linvor). We need to enter pin 1234. | |||
# Open Blueterm and click setting > connect > linvor. We need to enter pin 1234 once more. | |||
# Test if it is working by entering 1 or 0. Look at the small LED next to pin 13. | |||
* [http://www.kickstarter.com/projects/1608192864/rfduino-iphone-bluetooth-40-arduino-compatible-boa RFduino] and Company web site [http://www.opensourcerf.com/ here]. App is running on iphone. | |||
* Google: arduino bluetooth android and an [http://hackaday.com/2012/03/13/control-an-arduino-from-android-over-bluetooth/ example] by using JY-MCU Bluetooth module. | |||
* (not bluetooth) Xbee wireless http://www.youtube.com/watch?v=WTnC1bHoaDM. Information from [http://learn.parallax.com/KickStart/32440 Parallax]. | |||
* [http://learn.adafruit.com/introducing-bluefruit-ez-link?view=all Bluefruit EZ-Link] from Adafruit. | |||
=== Android Apps === | |||
* [https://play.google.com/store/apps/details?id=com.blueserial Blue Serial] - open source at github. It has been tested extensively to work with the JY-MCU module and should work for a wide range of devices. | |||
* [https://play.google.com/store/apps/details?id=com.techbitar.android.Andruino&hl=en Ardudroid] and [http://code.google.com/p/ardudroid/ source code]. | |||
* [https://github.com/42Bots/ArduinoBlueBot ArduinoBlueBot] | |||
== Accelerometers & Gyroscopes == | |||
From [http://astro-pi.org/hardware/ Astro Pi]: | |||
# A gyroscope measures the orientation of an object. | |||
# An accelerometer measures the speed of movement of an object. | |||
* http://www.robotshop.com/blog/en/arduino-5-minute-tutorials-lesson-7-accelerometers-gyros-imus-3634 | |||
* http://www.youtube.com/watch?v=HYUYbN2gRuQ | |||
* http://arduino.cc/en/Tutorial/ADXL3xx | |||
* http://www.instructables.com/id/Use-an-Accelerometer-and-Gyroscope-with-Arduino/ | |||
* http://www.instructables.com/id/Guide-to-gyro-and-accelerometer-with-Arduino-inclu/ (good demonstration) | |||
* http://dx.com/p/adxl345-digital-3-axis-gravity-acceleration-sensor-module-blue-149476 | |||
* https://www.sparkfun.com/tutorials/240 (from google: ADXL345 Arduino) | |||
[[File:adxl345.jpg|100px]] | |||
* http://learn.adafruit.com/adxl345-digital-accelerometer/programming Calibration (ADXL345) | |||
* Bump detection especially in robot http://letsmakerobots.com/node/33979 (MMA7361) | |||
* http://www.freetronics.com/pages/am3x-quickstart-guide#.Uk4clteVv0o (Understand output and calibration) | |||
* http://www.vetco.net/catalog/product_info.php?products_id=12790 (MMA7361) mentions applications for this device on your Arduino include navigation, motion sensing, speed/movement data logging, etc. Hey, you could make an Arduino-based pedometer. | |||
* http://ardadv.blogspot.com/2012/03/its-just-jump-to-left-part-ii.html | |||
== Python and Arduino == | |||
=== Monitor a movement (serial port) and send an email === | |||
http://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/python-code | |||
The arduino program is launched first. The arduino is used to send messages and python is used to read messages. So arduino program can be run without a Python program. | |||
=== Monitor files and send signals to LED === | |||
Write one arduino and one python file | |||
http://www.joakimlinde.se/microcontrollers/arduino/ or http://www.olgapanades.com/blog/controlling-arduino-with-python/ | |||
See also [http://playground.arduino.cc/Interfacing/Python arduino.cc] website for mire info about Python talking to Arduino via a serial interface. | |||
== Smart remote controller == | |||
http://makezine.com/projects/smart-remote-control/ | |||
== Arduino + Music == | |||
Arduino Music project running on Arduino Uno, Sparkfun Music Instrument Shield and Makey Makey. | |||
https://www.youtube.com/watch?v=tHq2SJG-5JU and more [http://wool.pe.kr/220209398449 at this link]. | |||
== Peizo == | |||
* https://www.arduino.cc/en/tutorial/knock | |||
* [http://hebertchad34.wix.com/chad-hebert#!Arduino-Seizure-Alarm/cmbz/557333f00cf24a198381de83 Seizure Alarm] | |||
== Temperature sensor == | |||
[http://makezine.com/projects/frozen-pipes-alarm/ Use Arduino to Avoid Frozen Plumbing This Winter] | |||
== Pedometer Watch, With Temperature, Altitude and Compass == | |||
http://www.instructables.com/id/Arduino-Watch-With-Altitude-Temperature-Compass-An/?ALLSTEPS using Arduino Pro Mini 3.3V | |||
== Lipo battery == | |||
* [http://www.instructables.com/id/DIY-SOLAR-LI-ION-LIPO-BATTERY-CHARGER/?ALLSTEPS Solar lipo battery charger] | |||
== Door sensor with Adafruit IO + IFTTT == | |||
* https://learn.adafruit.com/using-ifttt-with-adafruit-io?view=all and [http://lifehacker.com/build-a-simple-door-detector-with-ifttt-alerts-using-an-1737616575 Lifehacker] | |||
== [https://papersignals.withgoogle.com/ Paper Signals] == | |||
DIY beginner-level electronics projects with paper | |||
== RFID == | |||
[http://www.makeuseof.com/tag/diy-smart-lock-arduino-rfid/ DIY Smart Lock and Key With Arduino and RFID] | |||
== Single-key keyboard == | |||
* [https://blog.hackster.io/use-an-arduino-pro-micro-to-build-a-simple-single-key-bottle-cap-keyboard-14c3637472a1 Use an Arduino Pro Micro to Build a Simple, Single-Key, Bottle Cap Keyboard] | |||
* https://youtu.be/AGkbZXVQaqw?t=277 | |||
== Magnetic field == | |||
* [https://blog.arduino.cc/2019/07/25/visualizing-magnetic-fields-in-three-dimensions-with-an-arduino-magnetometer/ Visualizing magnetic fields in three dimensions with an Arduino magnetometer] | |||
* [https://smile.amazon.com/Meterk-Electromagnetic-Radiation-Detector-Dosimeter/dp/B0754VVW4W Meterk EMF Meter Electromagnetic Field Radiation Detector Handheld Mini Digital LCD EMF Detector Dosimeter Tester Counter] | |||
== HC-SR04 Ultrasonic Sensor == | |||
[https://www.hackster.io/331510/wash-a-lot-bot-a-diy-hand-washing-timer-2df500 Wash-A-Lot-Bot! A DIY Hand Washing Timer] | |||
== Kinetic digital clock == | |||
[https://blog.arduino.cc/2021/07/20/kinetic-digital-clock-takes-7-segment-displays-to-another-dimension/ Kinetic digital clock takes 7-segment displays to another dimension] | |||
== tinyML == | |||
* [https://blog.arduino.cc/2021/07/23/meet-your-new-table-tennis-coach-a-tinyml-powered-paddle Meet your new table tennis coach, a tinyML-powered paddle!] | |||
* [https://blog.arduino.cc/2022/07/02/arduin-row-uses-tinyml-to-improve-your-rowing-technique/ Arduin-Row uses tinyML to improve your rowing technique] | |||
= Electronics = | |||
== Oscilloscope == | |||
[https://blog.arduino.cc/2016/10/31/improve-your-programming-skills-with-an-oscilloscope/ IMPROVE YOUR PROGRAMMING SKILLS WITH AN OSCILLOSCOPE] | |||
== Clock cycles == | |||
The following code was used to measure the time spent on running 2 statements: one is delay(1000) and the other is Serial.println(). I got an output of 8 (most of time) or 4 (few times) microseconds. The code was modified from [http://arduino.cc/en/Reference/Micros Arduino Reference], [http://forum.arduino.cc/index.php/topic,6632.0.html this discussion] or [http://forum.arduino.cc/index.php/topic,61562.0.html/ another discussion]. | |||
Recall that nano second=10^(-9) second and micro second = 10^(-6) second. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). | |||
<pre> | |||
unsigned long time; | |||
void setup(){ | |||
Serial.begin(9600); | |||
} | |||
void loop(){ | |||
Serial.print("Time: "); | |||
time = micros(); | |||
delay(1000); // wait a second so as not to send massive amounts of data | |||
// We can also move this line to the end of loop() function to see the difference | |||
Serial.println(micros() - time); | |||
} | |||
</pre> | |||
If loop is empty, it will run at 16 MHz. If toggling a PIN is only line inside loop, it will run 16x10^6/2 loops since toggling a PIN took 2 clock cycles. | |||
On a slightly more complex example, | |||
<pre> | |||
unsigned long time; | |||
void setup(){ | |||
Serial.begin(9600); | |||
} | |||
void loop(){ | |||
Serial.print("Time: "); | |||
time = micros(); | |||
int angle = 0; | |||
while(angle < 180) | |||
Serial.println(sin(angle++/57.295)); | |||
Serial.println(micros() - time); | |||
// wait a second so as not to send massive amounts of data | |||
delay(1000); | |||
} | |||
</pre> | |||
it took 1061804 microseconds on my Arduino UNO; that is 16*10^6/10^6 * 1061804/ instructions to execute. Here, 16*10^6 number denotes 16 MHz of the CPU and 10^6 denotes the number of micro seconds. In other words, there are billions of instructions were executed in 4 lines. | |||
=== Instruction <> Cycle === | |||
http://forum.arduino.cc/index.php/topic,4324.0.html | |||
== [http://www.instructables.com/id/LEDs-for-Beginners/?ALLSTEPS Calculate resistor value for LED] == | |||
To figure out which resistor to use I used the formula: | |||
R = (V1 - V2) / I | |||
where: | |||
V1 = power supply voltage, | |||
V2 = LED voltage, | |||
I = LED current (usually 20mA which is .02A). | |||
For example, my LED is 1.7V, it takes 20mA (which is .02 A) of current and my supply is 4.5V. So the math is... | |||
R = (4.5V - 1.7V) / .02 A = 140 ohms | |||
Also putting LEDs in series would add voltages together while in parallel won't add voltages but draw more current. That is if we put LEDs together, we need to multiply the current that one LED draws by the total number of LEDs I was using. | |||
If we putting resistors in series, it would add ohms. But we put resistors in parallel, it would reduce resistance. | |||
== Timer == | |||
http://www.nunoalves.com/classes/spring_2012_cpe355/cpe355-02-f.pdf | |||
== Battery== | |||
* [http://hackaday.com/2014/12/16/battery-basics-choosing-a-battery-for-your-project/ How to choose batteries] and [https://www.youtube.com/watch?v=saxYilLJ7yw#t=537 youtube video]. | |||
* [http://gammon.com.au/power Power saving techniques for microprocessors] | |||
== Ah (Amp Hour) == | |||
http://overlandresource.com/what-is-an-amp-hour-and-how-to-calculate-battery-capacity | |||
== Interrupt == | |||
http://www.nunoalves.com/classes/spring_2012_cpe355/cpe355-02-b.pdf | |||
See Chapter 3 of Programming Arduino Next Steps. On Arduino UNO, there are 2 interrupts (PIN 2 and 3). A simple sketch to test interrupts (using '''attachInterrupt''' function) is | |||
<pre> | |||
// sketch 03_01_interrupts | |||
int ledPin = 13; | |||
void setup() | |||
{ | |||
pinMode(ledPin, OUTPUT); | |||
attachInterrupt(0, stuffHapenned, FALLING); | |||
} | |||
void loop() { } | |||
void stuffHapenned() | |||
{ | |||
digitalWrite(ledPin, HIGH); | |||
} | |||
</pre> | |||
Note that PIN 13 has an LED (also know "L" LED since there is a label "L" next to it) connected on UNO board so we don't need to manually connect another LED. See [http://arduino.cc/en/Main/arduinoBoardUno Arduino.cc] website. The first argument 0 is the interrupt number. On an Arduino Uno, interrupt 0 is pin D2 and interrupt 1 is D3. The hardware arrangement is | |||
<pre> | |||
D2 ---- 1 k resistor --- 5V | |||
|--- pushbutton --- Gnd | |||
</pre> | |||
== PWM/Analog Output == | |||
Using a [https://www.youtube.com/watch?v=Uhkq_9eufbM multimeter] (Sparkfun) | |||
See Chapter 1 of Programming Arduino Next Steps - Analog output. It also teaches how to use multimeter to measure analog output <Sketch_01_07_pwm>. It is noted that UNO does not have true analog output (Arduino Due has). On Arduino UNO board, the pins marked with little "~" (pins 3,5,6,9,10 and 11) can be used as analog outputs (with the '''analogWrite''' function). | |||
See Chapter 3 of Programming Arduino Next Steps <Sketch_03_03_1kHz>. | |||
== Memory == | |||
== I2C/TWI == | |||
== SPI == | |||
== UART == | |||
[https://www.makeuseof.com/how-uart-spi-i2c-serial-communications-work/ How UART, SPI, and I2C Serial Communications Work, and Why We Still Use Them] | |||
== USB Programming == | |||
== Network Programming == | |||
== Digital Signal Processing == | |||
== Relay module shield == | |||
* [https://makezine.com/2018/03/19/control-electronic-relays/ 4 Ways to Control Electronic Relays] | |||
* http://www.aliexpress.com/store/product/Four-relay-module4-relay-module-expansion-5V-12V/320981_598692534.html?tracelog=back_to_detail_b | |||
* http://www.glacialwanderer.com/hobbyrobotics/?p=9 | |||
* https://www.sparkfun.com/products/10684 | |||
* Tutorial http://www.sainsmart.com/8-channel-dc-5v-relay-module-for-arduino-pic-arm-dsp-avr-msp430-ttl-logic.html | |||
* Search amazon for relay module shield. The sellers tend to give connection instructions. | |||
* A relay from SparkFun Inventor Kit. My demo on [https://www.youtube.com/watch?v=o17tb7J6ekc Youtube]. The wiring looks complicated but it actually needs 5 (not 14) wires if we re-organize the wiring. | |||
[[File:RelayDiagram2.png|150px]] | |||
== Transistor == | |||
https://learn.sparkfun.com/tutorials/transistors | |||
== potentiometer == | |||
* Part: https://www.sparkfun.com/products/9806 | |||
* Example: SIK guide project 2 (use pot to control the blink rate of LED) from [https://www.sparkfun.com/products/retired/11227 Sparkfun Inventor Kit]. | |||
* On potentiometer, number 1 is 5v and number 3 is 0v although we can swap these 2 pins to get reverse effect when using the knob. | |||
* A copy of the SIK guide and example code are available at my [https://github.com/arraytools/SIK github] page. | |||
== Push button == | |||
See how it works at [http://www.varesano.net/blog/fabio/pushbuttons%20and%20tilt%20sensorsswitches%20how%20they%20work%20and%20some%20arduino%20usage%20examples this blog] and its references. The diagram below shows the connection (vertically displayed). It is seen legs are already connected in groups of two. When the push button is pressed all the 4 legs are connected. So two components can be A & B (same side) or A & D (opposite side). | |||
<pre> | |||
A B | |||
| | | |||
|--/ --| | |||
| | | |||
C D | |||
</pre> | |||
== Photoresistor == | |||
* http://playground.arduino.cc/Learning/PhotoResistor | |||
* https://blog.udemy.com/arduino-ldr/ | |||
* [https://www.arduino.cc/en/Reference/AnalogRead analogWrite()] documentation says it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. | |||
* [https://invent.sparkfun.com/cwists/preview/1117-toy-car-speed-trapx Toy Car Speed Trap] | |||
A night light example (tested on Arduino Nano) | |||
<syntaxhighlight lang='c'> | |||
/* Night light | |||
Connect the photoresistor one leg to pin 0, and pin to +5V | |||
Connect a resistor (around 10k is a good value, higher | |||
Turn on LED if it is dark and turn off LED if it is bright. | |||
---------------------------------------------------- | |||
PhotoR 10K | |||
+5 o---/\/\/--.--/\/\/---o GND | |||
| | |||
Anlg Pin 0 o----------- | |||
LED | |||
Dgt Pin 9 o-----------o GND | |||
---------------------------------------------------- | |||
*/ | |||
int lightPin = 0; //define an analog pin for Photo resistor | |||
int ledPin=9; //define a digital pin for LED | |||
int threshold = 400; // adjust it according to your need | |||
void setup() | |||
{ | |||
Serial.begin(9600); //Begin serial communcation | |||
pinMode(lightPin, INPUT); | |||
pinMode( ledPin, OUTPUT ); | |||
// can be replaced by the built-in small LED | |||
// pinMode(LED_BUILTIN, OUTPUT); | |||
} | |||
void loop() | |||
{ | |||
int v = analogRead(lightPin); | |||
Serial.println(v); | |||
if ( v < threshold) | |||
analogWrite(ledPin, 255); | |||
else | |||
analogWrite(ledPin, 0); | |||
delay(10); //short delay for faster response to light. | |||
} | |||
</syntaxhighlight> | |||
== IR resistor == | |||
[https://blog.arduino.cc/2018/02/27/measure-rpm-with-an-ir-sensor-and-arduino/ Measure RPM with an IR sensor and Arduino] | |||
== IR remote == | |||
[https://blog.arduino.cc/2022/02/12/controlling-any-ir-device-with-a-remote-and-some-hacking/ Controlling any IR device with a remote and some hacking] | |||
== Servo == | |||
* [http://makezine.com/2016/05/13/understanding-types-of-servo-motors-and-how-they-work/ Understanding Types of Servo Motors and How They Work] | |||
* [https://www.hackster.io/331510/wash-a-lot-bot-a-diy-hand-washing-timer-2df500 Wash-A-Lot-Bot! A DIY Hand Washing Timer] | |||
== Trinket == | |||
* http://www.adafruit.com/product/1501 | |||
* http://makezine.com/2014/12/19/small-but-mighty-meet-adafruit-trinket/ | |||
== Evermind sensors == | |||
* An article from [http://www.pcworld.com/article/2864216/evermind-review-this-minimally-intrusive-system-for-monitoring-your-elderly-parent-needs-to-do-more.html PCworld]. | |||
== Protoboard == | |||
http://makezine.com/2015/10/15/how-and-when-to-use-protoboard/ | |||
== My Misc Collection == | |||
* Transistor TIP 120 from [https://www.adafruit.com/products/976 adafruit]. Great for whenever you need to control medium to high-power electronics such as motors, solenoids, or 1W+ LED. | |||
* Transistor P2N2222AG from Sparkfun Inventor Kit. Used to control DC motor. | |||
* L298P Motor Shield For Arduino ([https://www.sparkfun.com/products/9815 Ardumoto]) from [http://www.ebay.com/itm/171167538405?_trksid=p2060778.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT ebay] and [http://arduino.cc/en/Main/ArduinoMotorShieldR3 arduino.cc]. An example code to control one or 2 motors is at [http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/?ALLSTEPS instructables.com]. | |||
* [http://www.ebay.com/itm/111320781130 5V L298N Dual Stepper Motor Driver Controller Board Module] includes standoff. Very large about 2inch x 2inch. | |||
* Diode 1N4001 from Sparkfun Inventor Kit. Used to control DC motor. | |||
* 74HC595 Shift Register from Sparkfun Inventor Kit. Used to control more LEDs. See an example from [https://learn.adafruit.com/adafruit-arduino-lesson-4-eight-leds/the-74hc595-shift-register Adafruit]. | |||
* Small IR sensor from [https://www.adafruit.com/products/157 Adafruit]. | |||
* MCP23017 i2c 16 input/output port expander from [https://www.adafruit.com/products/732 Adafruit]. It can be used to control both LCD and keypad. | |||
* 4-Bit level converter from [https://www.adafruit.com/product/757 Adafruit]. This is similar to [https://www.sparkfun.com/products/12009 Sparkfun]. See also its use in [http://www.instructables.com/id/How-to-make-a-BeagleBone-and-an-Arduino-communicat/ communication between BeagleBone and Arduino]. | |||
* Bluefruit EZ-Link from [https://www.adafruit.com/product/1588 Adafruit]. | |||
* Pulse sensor kit from Adafruit. | |||
* H-bridge (SN754410) motor drive 1A from [https://www.sparkfun.com/products/315 sparkfun]. Used to control DC motors. | |||
* Arduino Pro Mini 328 - 3.3V/8MHz from [https://www.sparkfun.com/products/11114 sparkfun]. | |||
* JY-MCU bluetooth module from [http://www.dx.com/p/jy-mcu-arduino-bluetooth-wireless-serial-port-module-104299#.U-Q2DXWx3AE dx.com] | |||
* MMA7361 Triple Axis Accelerometer Breakout from [http://www.dx.com/p/mma7361-accelerometer-module-tilt-slant-angle-sensor-149677#.U-Q2q3Wx3AE dx.com] | |||
* ADXL 345 3-Axis Gravity Acceleration Sensor Module from dx.com. | |||
* HC-SR04 Ultrasonic Sensor Distance Measuring Module from dx.com. Example code can be found [http://arduinobasics.blogspot.com/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html arduinobasics.blogspot.com/] ('''nice website including many arduino projects'''). Unbiased measure but very sensitive. Need only 2 digital pins to measure distance. [http://www.instructables.com/id/Arduino-Simple-Measuring-Device/ This] is another instruction which includes an LCD to show the distance. | |||
* Arduino ethernet shield. | |||
* Arduino LCD keypad shield from [http://www.dx.com/p/lcd-keypad-shield-for-arduino-duemilanove-lcd-1602-118059#.U-Q7rXWx3AE dx.com] | |||
* 2-Channel Relay Shield Module for Arduino from [http://www.dx.com/p/arduino-2-channel-relay-shield-module-red-144140#.U-Q7anWx3AE dx.com] | |||
* USB to uart adapter from [http://www.dx.com/p/usb-to-uart-5-pin-cp2102-module-serial-converter-81872#.U-Q7AnWx3AE dx.com]. | |||
* [http://www.pololu.com/product/1300 Pololu USB AVR Programmer]. Used for my 3pi Robot. | |||
* [http://www.dfrobot.com/index.php?route=product/product&product_id=91 wiichuck adapter]. | |||
* [http://www.dx.com/p/ir-infrared-motion-detection-sensor-module-dc-5v-20v-139624#.VBeERXWx3UY IR Infrared Motion Detection Sensor Module] The arduino sketch can be found on [http://www.instructables.com/id/PIR-Motion-Sensor-Tutorial/?ALLSTEPS instructables.com] and [http://playground.arduino.cc/Code/PIRsense arduino.cc]. | |||
* [http://www.dx.com/p/v27d-t1-0-56-3-digital-led-voltmeter-black-dc-3-2-30v-229568#.VBeEjHWx3UY V27D-T1 0.56" 3-Digital LED Voltmeter] | |||
* [http://www.dx.com/p/arduino-nano-v3-0-81877#.VBeEqnWx3UY Nano V3.0 for Arduino] (Atmega328P-AU) | |||
[[File:ProMini vs Nano.jpg|100px]] | |||
* [http://www.adafruit.com/product/1501 Adafruit Trinket - Mini 5V] | |||
* [http://www.adafruit.com/product/1609 Adafruit Perma-Proto Half-sized Breadboard] | |||
* [http://www.adafruit.com/product/2046 Potentiometer Knob] | |||
* [http://www.adafruit.com/product/1982 Adafruit 12-Key Capacitive Touch Sensor] breakout | |||
* [http://www.adafruit.com/product/1400 Adafruit Push-button Power Switch Breakout] | |||
* [http://www.adafruit.com/product/807 Dual H-Bridge Motor Driver for DC or Steppers] | |||
* [http://www.adafruit.com/product/1329 2.1mm DC Barrel Plug to Alligator Clips] | |||
* [http://www.adafruit.com/product/2077 Adafruit Proto Shield for Arduino Kit] | |||
* [http://www.adafruit.com/products/830 4 x AA Battery Holder with On/Off Switch] | |||
* [http://www.adafruit.com/product/276 5V 2A (2000mA) switching power supply] | |||
* [http://www.dx.com/p/lc-xl6009-dc-to-dc-adapter-non-isolated-booster-circuit-board-module-blue-black-239815#.VaBmtXUVhBc LC '''XL6009''' DC to DC step up power converter] (Input voltage: 3~32V; output voltage: 5~35V; input current: 4A max., 18mA (no load)) and the [http://www.instructables.com/id/Solar-powered-personal-fan/ project] of solar power personal fan. Other choice is '''LM2577S''' module such as [http://www.dx.com/p/dc-dc-lm2577-0-45-3-digital-voltage-step-up-boost-module-deep-blue-301104#.VaLiwXUVhBc this one]. | |||
* [https://www.sparkfun.com/products/10547 Sparkfun Simon says] | |||
* [http://www.dxsoul.com/product/1a-lithium-battery-charging-module-blue-901205188#.Vdje-3UVhBc 1A Lithium Battery Charging Module] | |||
* [http://www.dxsoul.com/product/ds3231-high-precision-real-time-clock-module-blue-3-3-5-5v-901222910#.VdjfIXUVhBc DS3231 High Precision Real-Time Clock Module] | |||
* [http://www.dxsoul.com/product/3-pin-slide-switch-diy-parts-red-10-piece-pack-901118187#.VdjfQnUVhBc 3-Pin Slide Switch DIY Parts] | |||
* [http://www.dxsoul.com/product/arduino-diy-part-buzzer-module-black-901138322#.VdjfY3UVhBc Passive Speaker Buzzer Module for Arduino] | |||
* [http://www.sainsmart.com/sainsmart-hdmi-vga-digital-9-9-inch-touch-screen-lcd-driver-board-for-raspberry-pi.html/ SainSmart HDMI/VGA Digital 9 Inch Touch Screen LCD+Driver Board] It works on Windows & Linux. See my screenshots and some notes of running on UDoo device on [[Udoo#Screenshot|here]]. The touch screen driver is available for download too though I haven't tested it yet. CF: [http://www.sainsmart.com/sainsmart-hdmi-vga-digital-9-9-inch-1024x600-lcd-driver-board-for-raspberry-pi.html A similar one] but there is no touch screen support and [http://www.sainsmart.com/sainsmart-hdmi-vga-digital-9-lcd-driver-board-for-raspberry-pi-60pin.html this one] but there is no LCD nor the touch functionality. | |||
* [https://www.sparkfun.com/products/13678 ESP8266] | |||
* [https://www.sparkfun.com/products/8483 Polymer Lithium Ion Battery - 2000mAh]. I also need a Lipo charger like [https://www.adafruit.com/products/1944 adafruit] or [http://www.aliexpress.com/item/DIY-Power-Cell-Charger-Booster-Battery-Charger-Module-Free-Shipping/32321312440.html sparkfun]. | |||
* [https://www.sparkfun.com/products/11620 Slide Pot - Small (10k Linear Taper)] | |||
= 3D = | |||
== Software == | |||
* [http://123dapp.com/design 123D Design] from AUTODESK and an [http://3dprint.com/93721/picture-raspberry-pi-camera/ article] (The ‘Pi’cture: A 3D Printed Raspberry Pi Camera You Can Build Yourself) mentioned about it. | |||
= Embedded System = | |||
* [http://www.amazon.com/Introduction-Embedded-Systems-Development-Environment/dp/1608454983 Introduction to Embedded Systems: Using ANSI C and the Arduino Development Environment] by David Russell (Author), Mitchell Thornton (Series Editor) | |||
* Chapter 3 (Exploring Embedded Linux Systems] of Exploring Beaglebone by Derek Molloy. | |||
= Open source hardware = | |||
[https://opensource.com/article/17/5/8-ways-get-started-open-source-hardware 8 ways to get started with open source hardware] | |||
= Soldering = | |||
* [https://www.makeuseof.com/tag/learn-solder-simple-tips-projects/ Learn How to Solder With These Simple Tips and Projects] | |||
* [https://www.makeuseof.com/tag/best-soldering-iron/ Soldering iron] | |||
= Seller, Community = | |||
* http://arduino.cc/en/Main/Buy | |||
* [http://arduino.cc/forum/ Arduino.cc forum] | |||
* [http://www.adafruit.com/ adafruit] and [http://forums.adafruit.com/ Adafruit forum] | |||
* [https://www.sparkfun.com/ Sparkfun] | |||
* [http://www.parallax.com/Resources/ResourcesHome/tabid/473/Default.aspx Parallax Resources and Forum] | |||
* [http://www.element14.com/community/index.jspa Element14 Community] | |||
* Newark | |||
The CanaKit's [https://www.sparkfun.com/products/retired/11227 Sparkfun inventor's kit for Arduino] (SX10173) contains lots of stuff like [https://www.sparkfun.com/products/8588 1N4148 diode], P2N222AG NPN transistor ([http://www.youtube.com/watch?v=vVNztmsPebg youtube], potentiometer, 5V relay, temperature sensor ([https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor TMP36GZ]), 74HC595 shift register, hobby servo and photo resistor/photocell. Circ-03 (or Circ-12 on the new guide) teaches how to use P2N222AG transistor and 1N4001 Diode to spin a motor. See the SIK guide in pdf from the above link. The resistors it has included have 330 ohm, 10K. I also purchased 3.3M resistors for another application. | |||
In the [http://www.adafruit.com/products/193 Arduino budget pack], it includes 100 ohm, 1k and 10k resistors and photocell. | |||
http://lifehacker.com/how-can-i-get-into-a-new-hobby-without-breaking-the-ban-489189582 | |||
Latest revision as of 10:49, 16 January 2023
Hardware
Uno
The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.
This means that the Uno can execute 16 million 8 bit instructions per second.
Basic facts:
- It has digital input/output pins and analog inputs but no analog output pins. See PWM/Analog output.
- Each pin can only handle 40 mA of current. So there is a chance to blow the chip if you directly connect motors to it without a motor controller (That's what people invented H-bridge), not to say about changing current. See also the discussion stackexchange and arduino forums (Google: why we should not direct connect motor to arduino).
Due
The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU (datasheet). It is the first Arduino board based on a 32-bit ARM core microcontroller. It has 54 digital input/output pins (of which 12 can be used as PWM outputs), 12 analog inputs, 4 UARTs (hardware serial ports), a 84 MHz clock, an USB OTG capable connection, 2 DAC (digital to analog), 2 TWI, a power jack, an SPI header, a JTAG header, a reset button and an erase button.
Since UNO is 8-bit and DUE is 32-bit, there is difference in terms of storage. On the Arduino Uno (and other ATMega based boards) an int stores a 16-bit (2-byte) value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1).
On the Arduino Due, an int stores a 32-bit (4-byte) value. This yields a range of -2,147,483,648 to 2,147,483,647 (minimum value of -2^31 and a maximum value of (2^31) - 1). See http://arduino.cc/en/Reference/int and Discussion of comparing UNO & Due.
Another interesting point is neither of them have floating point support (Beaglebone bone and Rasp Pi do have FP).
Comparison of Boards
- https://www.sparkfun.com/arduino_guide
- http://arduino.cc/en/Products.Compare
- http://learn.adafruit.com/adafruit-arduino-selection-guide/arduino-comparison-chart
- http://www.tested.com/tech/robots/456466-know-your-arduino-guide-most-common-boards/
Memory
- http://playground.arduino.cc/Learning/Memory
- http://learn.adafruit.com/memories-of-an-arduino/arduino-memories
- Flash memory (program space), is where the Arduino sketch is stored. Flash memory is the same technology used for thumb-drives and SD cards. It is non-volatile, so your program will still be there when the system is powered off.
- SRAM (static random access memory) is where the sketch creates and manipulates variables when it runs. This memory includes 3 kinds of space: static data, heap and stack.
- EEPROM is memory space that programmers can use to store long-term information.
Wio Terminal
Arduino alternatives
- https://www.makeuseof.com/tag/best-arduino-alternative-microcontrollers/
- NodeMCU
- Teensy 3
- MSP430 Launchpad
- STM32
- PocketBeagle
Arduino IDE
The serial port is ttyACM0 for UNO, ttyUSB0 for Nano under my Ubuntu. To detect the serial port device, first run
ls -t /dev/tty*
Then plug in Arduino UNO and run the above command again. See playground.arduino.cc.
Source code in Github
https://github.com/arduino/Arduino/tree/master/hardware/arduino/cores/arduino
Install Arduino IDE under Ubuntu
- http://askubuntu.com/questions/107619/how-do-i-install-the-arduino-ide
- http://blog.markloiseau.com/2012/05/install-arduino-ubuntu/
Using source code (For some reason, I cannot find ~/.arduino/preference.txt file with this approach)
sudo apt-get install arduino-core sudo apt-get install openjdk-7-jre # Go to http://arduino.cc/en/main/software to download the latest software tar xzvf arduino-1.0.5-linux32.tgz cd arduino-1.0.5 sudo ./arduino
The 2nd approach is (I think it is better since I can find and modify ~/.arduino/preference.txt file).
sudo apt-get update && sudo apt-get install arduino arduino-core
After Arduino IDE is installed, I can change the font (Line 11 of preference.txt file) from Monospaced DejaVu Sans Mono,plain,12 to something like
editor.font=DejaVu Sans Mono,bold,16 OR editor.font=Courier New,bold,16
PS. Open AbiWord to check available fonts in Ubuntu OS.
Update 6/27/2016: I download the tar ball from official website in order to get the latest version. Running <install.sh> from Arduino 1.6.9 under Ubuntu
- sudo is not needed. Just run <install.sh>
$ '/home/brb/binary/arduino-1.6.9/install.sh' Adding desktop shortcut, menu item and file associations for Arduino IDE... done!
- if we open Arduino as a regular user, we cannot write to the serial port. So we need to run sudo usermod -a -G dialout <username> to fix it. Remember to log out and log in again for this change to take effect. See https://www.arduino.cc/en/Guide/Linux.
- Not sure if this is necessary: sudo chmod a+rw /dev/ttyACM0 (It seems if I issue it, I don't need to log out & log in)
Using Arduino IDE as user instead sudo in Ubuntu
http://www.mycontraption.com/installing-arduino-on-ubuntu-12-10/
brb@brb-P45T-A:~$ ls -lt /dev | more total 0 crw-rw-rw- 1 root tty 5, 2 Sep 15 20:07 ptmx crw-rw-rw- 1 root tty 5, 0 Sep 15 20:06 tty drwxr-xr-x 2 root root 3820 Sep 15 20:06 char drwxr-xr-x 4 root root 80 Sep 15 20:06 serial crw-rw---- 1 root dialout 166, 0 Sep 15 20:06 ttyACM0 crw-rw---- 1 root dialout 4, 64 Sep 15 19:51 ttyS0 sudo usermod -a -G dialout yourusename
Then log out and log in again. Type 'groups' to see if the current user belongs to dialout group.
No only we don't need to use 'sudo' to run arduino, we can also save a sketch under user's ownership.
The 2nd trick is to make the menu on the Arduino IDE to be visible. Open and edit arduino-1.0.5/arduino file, and then modify the last line so it becomes "java processing.app.Base". What this essentially does is uses the Arduino look and feel instead of the GTK version.
Arduino Reset Button
To "reset" the Uno power it down, hold down the reset button, and, while still holding the reset button down, power it up again. This will prevent the existing sketch from running. You can then upload a new sketch.
ArduBlock - Scratch like interface for Arduino
ArduBlock is a programming environment designed to make “physical computing with Arduino as easy as drag-and-drop.” Instead of writing code, worrying about syntax, and (mis)placing semicolons, ArduBlock allows you to visually program with an snapped-together list of code blocks.
- http://blog.ardublock.com/engetting-started-ardublockzhardublock/
- http://sourceforge.net/projects/ardublock/ (source code)
- https://learn.sparkfun.com/tutorials/alternative-arduino-interfaces/ardublock
Arduino Library
For example, if we want to try the pong game which uses the vgax library, we can copy the vgax folder and paste it to arduino-1.6.5-r5/libraries folder (I am using Linux OS). The library will appear under Arduino IDE -> File -> Example when we launch the IDE next time.
Arduino Web Editor
THE LIBRARY MANAGER IS NOW AVAILABLE ON THE WEB EDITOR!
Arduino Simulators
4 Arduino Simulators You Can Use in Your Electronics Projects
C users
- http://www.javiervalcarce.eu/wiki/Program_Arduino_with_AVR-GCC
- http://code.google.com/p/libarduino/
- http://www.joakimlinde.se/microcontrollers/arduino/avr/
R
Alternatives for retrieving sensor data from Arduino compatible microcontrollers into R
Programming using Scratch
Since this will involve uploading a firmware to Arduino, we now can only do programming using S4A. We can go back to use Arduino IDE for programming if we want to discard using S4A.
s4a is available as deb package.
Simple example (button & LED)
- Connect wires according to http://s4a.cat/. I use 330 Ohm resistor. The digital pin I use is 3, not 2.
- sudo s4a to launch S4A
- Follow the instruction in instructables.com to try 1. LED blinking and 2. LED and button in S4A.
One problem with this idea is the arduino board needs to be connected to computer all the time.
Tutorials
- https://www.youtube.com/watch?v=OkSGiko5EE0&list=PLE0C7D8863F6DACCE
- http://www.nunoalves.com/classes/spring_2012_cpe355/
- Arduino Tip, Tricks and Techniques
- Serial monitor
- http://tronixstuff.wordpress.com/tutorials/
- http://startingelectronics.com/beginners/
- https://www.sparkfun.com/tutorials/57
- http://www.ladyada.net/learn/arduino/
- Stepper motor See the example 1 where the motor turns in two directions and example 2 code where the motor turns continuously in one direction. The connection of motor to the arduino is very simple: Just 1. connecting IN1, IN2, IN3, IN4 to pin 8,9,10,11 and 2. connecting GND to GND in arduino and VCC to 5v in arduino. The connection of 28BYJ-48 motor to uln2003 is obvious. See my video on Youtube.
- Micro servo. See http://magnusglad.wordpress.com/2013/03/13/tested-my-sg90-servo-today/ for an instruction and my video on Youtube.
- Check google to see the difference between dc motor and servo. This site explains the difference among dc motor, servo motor and step motor. Adafruit.com has an article to explain stepper motors.
- Adafruit motor shield v2. It can be used to control DC motors, stepper motors and servos. It can drive up to 4 DC motors or 2 stepper motors.
Arduino IDE, Books, Forums
IDE
- On ubuntu, we need to run arduino using sudo; otherwise, the serial port is greyed out.
- Save/Save As will create a folder and a file with the extension .ino.
- Cheat sheet https://dlnmh9ip6v2uc.cloudfront.net/learn/materials/8/Arduino_Cheat_Sheet.pdf
- For 'Prescaler.h' library, it is not part of arduino IDE. So the way I do is
# Create a file 'Prescaler.h' under ~/sketchbook/ # ln -s /home/brb/sketchbook/Prescaler.h ~/binary/arduino-1.0.5/hardware/arduino/cores/arduino/Prescaler.h # nano ~/sketchbook/Prescaler.h and change WProgram.h to Arduino.h. # OK. It is the time to run sketch_05_01_prescale from Arduino IDE > sketchbook > ArduinoNextSteps.
See the post.
Books
- Programming Arduino and Programming Arduino Next Steps by Simon Monk.
- Getting Started with Arduino by Massimo Banzi.
- Practical Arduino by Jon Oxer and Hugh Blemings.
- Exploring Arduino: Tools and Techniques for Engineering Wizardry and Book's website.
- Arduino Workshop: A Hands-On Introduction with 65 Projects
- Make: Sensors: A Hands-On Primer for Monitoring the Real World with Arduino and Raspberry Pi
Forums
- (Blog) Make and Instructables.
- Freeduino
Processing/Graph
It is possible to send a byte of data from the Arduino to a personal computer and graph the result. This is called serial communication because the connection appears to both the Arduino and the computer as a serial port, even though it may actually use a USB cable.
- First, download and install Processing software (currently 2.0.3)
- Check out http://arduino.cc/en/Tutorial/Graph for wiring. Very simple. Just one potentiometer and 3 wires (one goes to gnd, 2nd one goes to 5v and the 3rd one connects to A0).
- Check out http://www.dustynrobots.com/news/seeing-sensors-how-to-visualize-and-save-arduino-sensed-data/ for the idea of how to plot the analog data using Processing. It contains 2 steps: 1. Open Arduino IDE (sudo is necessary if OS is not Windows) and compile/run a code to print byte to serial using Serial.write(). 2. Open Processing (sudo is necessary if OS is not Windows) and run a code. We shall be able to see a beautiful streaming graph appearing on screen. Both codes are attached below.
Arduino
int sensorPin = A0; // analog input pin to hook the sensor to int sensorValue = 0; // variable to store the value coming from the sensor void setup() { Serial.begin(9600); // initialize serial communications } void loop() { sensorValue = analogRead(sensorPin)/4; // read the value from the sensor Serial.write(sensorValue); // print bytes to serial delay(10); }
Processing
import processing.serial.*; Serial myPort; // The serial port float xPos = 0; // horizontal position of the graph void setup () { size(800, 600); // window size // List all the available serial ports println(Serial.list()); String portName = Serial.list()[0]; myPort = new Serial(this, portName, 9600); background(#EDA430); } void draw () { // nothing happens in draw. It all happens in SerialEvent() } void serialEvent (Serial myPort) { // get the byte: int inByte = myPort.read(); // print it: println(inByte); float yPos = height - inByte; // draw the line in a pretty color: stroke(#A8D9A7); line(xPos, height, xPos, height - inByte); // at the edge of the screen, go back to the beginning: if (xPos >= width) { xPos = 0; // clear the screen by resetting the background: background(#081640); } else { // increment the horizontal position for the next reading: xPos++; } }
More:
Data Logging
- Plotly and API
- https://learn.sparkfun.com/tutorials/internet-datalogging-with-arduino-and-xbee-wifi
- Google Spreadsheet
Robot based on BOE shield for Arduino
My robot is based on 'Shield for Arduino' which means I can use Arduino IDE + C code style to write my code instead of using PBASIC programming which is used in another similar robot.
Projects from each chapters
Chapter 3. Activity 2: Re-test the servos
We can use Pins 11 and 12 instead of 12 and 13. Be sure to adjust your code accordingly.
Chapter 4. Activity 2
First time we disconnect robot from the computer and let it go (forward, left turn, right turn and back ward).
Chapter 5 (Whiskers). Activity 3 or 4
See my robot is in action on http://www.youtube.com/watch?v=sjzQI6GHe3w.
Chapter 7 (Infrared headlight). Activity 4
Similar to Chapter 5 but IR detectors are used. See the robot in action on http://www.youtube.com/watch?v=K5pIZ5XcP7Y.
Activity 7: Drop-off detection (Very Cool).
This site contains some more information to use infrared LED to avoid object by testing on arduino board.
Using regular IR remote controll
The Arduino code provided for this project makes the BOE Shield-Bot recognize Sony IR remote signals only! For example, the BRIGHTSTAR universal remote sold by Parallax is programmed by holding the SET-UP button down until an LED on the remote lights up, then entering the code 605. Different models of remotes may use different codes and configuration methods. Check your remote's docs! See the instruction and arduino code in IR Remote Controlled Shield-Bot.
Using ping))) with BOEShield
Information and arduino code from Parallax. I find the code by searching within parallax.com. See http://thoughtfix.com/blog/2012/3/25/arduino-boe-shield-ping-and-a-servo.html for arduino code. Some modified code here. My recorded video is available on Youtube.
Other robots
- (Tutorial) http://www.foxytronics.com/learn/robots/how-to-make-your-first-arduino-robot
- http://www.robotshop.com/
- http://www.robotsimple.com/
- http://www.ez-robot.com/ including EZ-B Bluetooth Servo Tamiya Bulldozer Robot
- Arduino controlled Bluetooth-bot and this one.
- (Book) Arduino Robotics By John-David Warren , Josh Adams , Harald Molle
- Robot gift guide from makezine.com.
Video
The astounding athletic power of quadcopters from TED.
Kit
Projects
Special Projects
- Go kart
- Smart Glasses
- Wireless Keylogger and the original post
- Ping pong with Arduino UNO which makes use of the vgax library (VGA library for Arduino UNO). The library implement a 120x60px framebuffer. The library also implements an async tone (audio) generation too. As mentioned in the forum, it is OK to use only one potentiometer and button. The two paddles move in parallel in this case.
- How To Recreate The Classic Pong Game Using Arduino
- Connecting the real world to R with an Arduino
- Heart Rate Monitor. Select Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328 in Arduino IDE. I need to change the Serial.list()[32] in sketch since the output on processing shows I have /dev/ttyS0 /dev/ttyS1 ... /dev/ttyS31 /dev/ttyUSB0. Processing does not need to or have no way to select the Arduino board on its GUI.
- Check your heart rate with this Star Trek-inspired handheld monitor
- This is a DIY heart rate monitor from instructables.com.
- Arduino plays timberman
- Arduino simulator puts you in the driver’s seat of a toy car
- Arduino CPU monitor.
- http://www.instructables.com/id/System-Monitor-With-Arduino-and-7-Segment-Display/ Linux Mint was used.
http://www.linuxuser.co.uk/tutorials/arduino-cpu-monitorhttps://www.gadgetdaily.xyz/arduino-cpu-monitor/ We get real-time CPU data and display it with a series of LEDs. We’ll also look into adjusting the brightness of those LEDs with a potentiometer, and running the app as a background process with Forever.js.- https://blogs.oracle.com/ksplice/entry/building_a_physical_cpu_load
- http://forum.arduino.cc/index.php?topic=171114.0 (windows)
- http://forum.arduino.cc/index.php?topic=302422.0 (16x2 lcd)
- https://www.raspberrypi.org/forums/viewtopic.php?t=114620&p=784702 Raspberry Pi
- CPU and RAM Usage Monitor (Windows & Linux)
- http://www.instructables.com/id/Arduino-CPURAM-usage-monitor-LCD/ (Windows + VB.net). The key is how to send data to the serial port from PC (Windows or Linux). The serial port could be /dev/ttyS0 or /dev/ttyS1 or /dev/ttyACM0 for Linux. How To Check and Use Serial Ports Under Linux from cyberciti.biz. You have to plug in an Arduino in order to get the port. See also Udoo > Minicom. The arduino code is very simple
#include <LiquidCrystal.h> //Set's lcd to the Arduino's ports LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); Serial.begin(9600); } void loop() { String content = ""; char character; while(Serial.available()) { character = Serial.read(); content.concat(character); } if (content != "") { if (content == "`") { content = ""; lcd.setCursor(0,1); } if (content == "*") { content = ""; lcd.setCursor(0,0); } Serial.println(content); lcd.print(content); } if (content == "~") { lcd.clear(); } }
Simple LED
GND --- wire --- 300 Ohm --- short end of LED --- long end of LED --- wire --- 5v/3.3v.
The 300 Ohm resistor can be replaced by anyone between 100 Ohm and 10K Ohm.
7 Segment LED
- Design. Note that for common anode, we need to connect pin 3, 8 to 5V and for common cathode we want to connect pin 3,8 to gnd.
- Arduino example (digits). I need to change seven_seg_digit to 1-seven_seg_digit in digitWrite() function since mine has common anode.
- How to represent all alphabet
LCD Keypad shield
This Arduino shield includes a 16x2 HD44780 White on Blue LCD module and a 5 push button keypad for menu selection and user interface programming. The shield can be directly used by opening Arduino > Example > CrystalLCD > Autoscroll as long as we have changed the pin numbers (see comments from dx.com); changing the lcd object to the following
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // instead of lcd(12, 11, 5, 4, 3, 2);
Note that there are two versions of shield.
- (Wiki) http://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_%28SKU:_DFR0009%29 It seems only 8 pins are used. So if the shield is placed on a breadboard we can make use the other pins on Arduino.
- (Hello World with timing) Arduino IDE > Examples > LiquidCrystal > HelloWorld.
- (Display buttons/LCD Keypad) http://arduinotronics.blogspot.com/2012/06/lcd-keypad-shield.html. The source code is in github. A simpler code http://www.hobbytronics.co.uk/arduino-lcd-keypad-shield works for me.
- (Display barchart) http://www.mathias-wilhelm.de/arduino/shields/dfrobot-lcd-16x2-shield/ I saved the source code in my github.
- (Buy from) http://dx.com/p/lcd-keypad-shield-for-arduino-duemilanove-lcd-1602-118059#.UtyCQNdOnoo
- A diagram shows which pins are used or available
Control DC motors
- Magician Chassis
- Adafruit's arduino lesson 13 gives an instruction of controlling the speed of a small DC motor, PN2222 Transistor, 1N4001 diode and 270 Ω Resistor (red, purple, brown stripes). A similar instruction was given by Make.
- DC motor reversing from Adafruit arduino lesson 15. It uses a L293D IC, 10 kΩ variable resistor (pot) and Tactile push switch.
- DC motor's direction using an H-bridge from itp.nyu.edu.
- An instruction given by Jeremyblum.com.
- L298P Motor Shield For Arduino (Ardumoto) from ebay and arduino.cc. Use 3 pins to control each of 2 motors (direction, speed, brake).
- 5V L298N Dual Stepper Motor Driver Controller Board Module from ebay. It includes standoff and is very large (~ 2 inch x 2 inch).
- PC fan motor (brushless): using TIP120 transistor to control motors and high power devices.
- Reading pc fan rpm. The pc fan can be just powered by a 9V battery. I save a copy of the code in github. PS. 9 wires and 3 crocodile clips in addition to 1 PC case fan are needed.
Bubble blaster
https://toemat.com/bubble-gun/
Using Web to read/write GPIO (it works)
http://uggettif.blogspot.com/2012/11/controlling-arduino-from-web-page.html
Using Node/Websocket to create a Web page and control Arduino
- http://danieldvork.in/arduino-controlled-html5-etch-a-sketch-using-node-js-and-websockets/
- http://semu.github.io/noduino/
- http://www.olivierklaver.com/chapter_3.html
Ethernet Shield
Test Ethernet Shield
Use sketch_12_01_dhcp from Programming Arduino Next Steps. Or
// sketch_12_01_dhcp #include <SPI.h> #include <Ethernet.h> byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; void setup() { Serial.begin(9600); while (!Serial){}; if (Ethernet.begin(mac)) { Serial.println(Ethernet.localIP()); } else { Serial.println("Could not connect to network"); } } void loop() { }
Open Serial Monitor. Mine shows 10.42.0.37 when I use ethernet 1 from PC to share the internet connection.
Control light from a browser
Blynk - mobile app
Blynk allows to create an iOs, Android app for any connected project or product based on Arduino, Raspberry, ESP8266, and other hardware.
Getting Started With Blynk: Simple DIY IoT Devices
ESP8266
How to Make Your Own Wi-Fi Connected Button With ESP8266
ESP32
How to Detect Room Presence and Automate Smart Home Devices With ESP32
Arduino with bluetooth
- JY-MCU Bluetooth for Windows/Linux and Android. The JY-MCU is also called HC-06.
It works as the instruction on Windows Vista computer. However on Ubuntu computer (I use my bluetooth dongle obtained from Udoo) I need to
- Make sure the arduino code has been uploaded to arduino uno via USB cable when bluetooth module is not connected to arduino. After the code has been uploaded to arduino, we can connect the bluetooth module to arduino and then power on arduino.
- Don't use Ubuntu default bluetooth utility. Download and install blueman (Bluetooth manager) from software center.
- Paired it to jy-mcu (device name is linvor) . Enter pin number 1234.
- Right click on 'linvor' in blueman and click setup. The default option 'serial port' is good so we can click 'forward' button. At this time, the connection should be successful. The screen also shows the device is on /dev/rfcomm0.
- Open Arduino IDE. The IDE does not need to have any code there. Select Tools > board > 'Arduino Uno'. For some reason Arduino IDE 1.0.5 does not find the port /dev/rfcomm0 but Arduino IDE 1.5.7 finds the port. So I use Arduino IDE 1.5.7 to test jy-mcu.
- Open the serial monitor and make sure the baud rate is 9600. Type H to turn on the LED and L to turn off the LED. That's it.
For Android device, it works too by following the author's instruction.
- Download the free Blueterm app. P.S. I found from play store that the app Bluetooth Serial Controller made by Next Prototypes works well - we can assign commands (in terms ASCII) to different buttons and we can hide buttons.
- Rx on jy-mcu is connected to arduino Pin 2 and Tx is connected to Pin 4. Note that I did not use shift register/resistors between Rx on jy-mcu and Android.
- Open Android > Bluetooth > Setting to connect jy-mcu (linvor). We need to enter pin 1234.
- Open Blueterm and click setting > connect > linvor. We need to enter pin 1234 once more.
- Test if it is working by entering 1 or 0. Look at the small LED next to pin 13.
- RFduino and Company web site here. App is running on iphone.
- Google: arduino bluetooth android and an example by using JY-MCU Bluetooth module.
- (not bluetooth) Xbee wireless http://www.youtube.com/watch?v=WTnC1bHoaDM. Information from Parallax.
- Bluefruit EZ-Link from Adafruit.
Android Apps
- Blue Serial - open source at github. It has been tested extensively to work with the JY-MCU module and should work for a wide range of devices.
- Ardudroid and source code.
- ArduinoBlueBot
Accelerometers & Gyroscopes
From Astro Pi:
- A gyroscope measures the orientation of an object.
- An accelerometer measures the speed of movement of an object.
- http://www.robotshop.com/blog/en/arduino-5-minute-tutorials-lesson-7-accelerometers-gyros-imus-3634
- http://www.youtube.com/watch?v=HYUYbN2gRuQ
- http://arduino.cc/en/Tutorial/ADXL3xx
- http://www.instructables.com/id/Use-an-Accelerometer-and-Gyroscope-with-Arduino/
- http://www.instructables.com/id/Guide-to-gyro-and-accelerometer-with-Arduino-inclu/ (good demonstration)
- http://dx.com/p/adxl345-digital-3-axis-gravity-acceleration-sensor-module-blue-149476
- https://www.sparkfun.com/tutorials/240 (from google: ADXL345 Arduino)
- http://learn.adafruit.com/adxl345-digital-accelerometer/programming Calibration (ADXL345)
- Bump detection especially in robot http://letsmakerobots.com/node/33979 (MMA7361)
- http://www.freetronics.com/pages/am3x-quickstart-guide#.Uk4clteVv0o (Understand output and calibration)
- http://www.vetco.net/catalog/product_info.php?products_id=12790 (MMA7361) mentions applications for this device on your Arduino include navigation, motion sensing, speed/movement data logging, etc. Hey, you could make an Arduino-based pedometer.
- http://ardadv.blogspot.com/2012/03/its-just-jump-to-left-part-ii.html
Python and Arduino
Monitor a movement (serial port) and send an email
http://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/python-code
The arduino program is launched first. The arduino is used to send messages and python is used to read messages. So arduino program can be run without a Python program.
Monitor files and send signals to LED
Write one arduino and one python file http://www.joakimlinde.se/microcontrollers/arduino/ or http://www.olgapanades.com/blog/controlling-arduino-with-python/
See also arduino.cc website for mire info about Python talking to Arduino via a serial interface.
Smart remote controller
http://makezine.com/projects/smart-remote-control/
Arduino + Music
Arduino Music project running on Arduino Uno, Sparkfun Music Instrument Shield and Makey Makey.
https://www.youtube.com/watch?v=tHq2SJG-5JU and more at this link.
Peizo
Temperature sensor
Use Arduino to Avoid Frozen Plumbing This Winter
Pedometer Watch, With Temperature, Altitude and Compass
http://www.instructables.com/id/Arduino-Watch-With-Altitude-Temperature-Compass-An/?ALLSTEPS using Arduino Pro Mini 3.3V
Lipo battery
Door sensor with Adafruit IO + IFTTT
Paper Signals
DIY beginner-level electronics projects with paper
RFID
DIY Smart Lock and Key With Arduino and RFID
Single-key keyboard
- Use an Arduino Pro Micro to Build a Simple, Single-Key, Bottle Cap Keyboard
- https://youtu.be/AGkbZXVQaqw?t=277
Magnetic field
- Visualizing magnetic fields in three dimensions with an Arduino magnetometer
- Meterk EMF Meter Electromagnetic Field Radiation Detector Handheld Mini Digital LCD EMF Detector Dosimeter Tester Counter
HC-SR04 Ultrasonic Sensor
Wash-A-Lot-Bot! A DIY Hand Washing Timer
Kinetic digital clock
Kinetic digital clock takes 7-segment displays to another dimension
tinyML
- Meet your new table tennis coach, a tinyML-powered paddle!
- Arduin-Row uses tinyML to improve your rowing technique
Electronics
Oscilloscope
IMPROVE YOUR PROGRAMMING SKILLS WITH AN OSCILLOSCOPE
Clock cycles
The following code was used to measure the time spent on running 2 statements: one is delay(1000) and the other is Serial.println(). I got an output of 8 (most of time) or 4 (few times) microseconds. The code was modified from Arduino Reference, this discussion or another discussion.
Recall that nano second=10^(-9) second and micro second = 10^(-6) second. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four).
unsigned long time; void setup(){ Serial.begin(9600); } void loop(){ Serial.print("Time: "); time = micros(); delay(1000); // wait a second so as not to send massive amounts of data // We can also move this line to the end of loop() function to see the difference Serial.println(micros() - time); }
If loop is empty, it will run at 16 MHz. If toggling a PIN is only line inside loop, it will run 16x10^6/2 loops since toggling a PIN took 2 clock cycles.
On a slightly more complex example,
unsigned long time; void setup(){ Serial.begin(9600); } void loop(){ Serial.print("Time: "); time = micros(); int angle = 0; while(angle < 180) Serial.println(sin(angle++/57.295)); Serial.println(micros() - time); // wait a second so as not to send massive amounts of data delay(1000); }
it took 1061804 microseconds on my Arduino UNO; that is 16*10^6/10^6 * 1061804/ instructions to execute. Here, 16*10^6 number denotes 16 MHz of the CPU and 10^6 denotes the number of micro seconds. In other words, there are billions of instructions were executed in 4 lines.
Instruction <> Cycle
http://forum.arduino.cc/index.php/topic,4324.0.html
Calculate resistor value for LED
To figure out which resistor to use I used the formula: R = (V1 - V2) / I
where: V1 = power supply voltage, V2 = LED voltage, I = LED current (usually 20mA which is .02A).
For example, my LED is 1.7V, it takes 20mA (which is .02 A) of current and my supply is 4.5V. So the math is...
R = (4.5V - 1.7V) / .02 A = 140 ohms
Also putting LEDs in series would add voltages together while in parallel won't add voltages but draw more current. That is if we put LEDs together, we need to multiply the current that one LED draws by the total number of LEDs I was using.
If we putting resistors in series, it would add ohms. But we put resistors in parallel, it would reduce resistance.
Timer
http://www.nunoalves.com/classes/spring_2012_cpe355/cpe355-02-f.pdf
Battery
Ah (Amp Hour)
http://overlandresource.com/what-is-an-amp-hour-and-how-to-calculate-battery-capacity
Interrupt
http://www.nunoalves.com/classes/spring_2012_cpe355/cpe355-02-b.pdf
See Chapter 3 of Programming Arduino Next Steps. On Arduino UNO, there are 2 interrupts (PIN 2 and 3). A simple sketch to test interrupts (using attachInterrupt function) is
// sketch 03_01_interrupts int ledPin = 13; void setup() { pinMode(ledPin, OUTPUT); attachInterrupt(0, stuffHapenned, FALLING); } void loop() { } void stuffHapenned() { digitalWrite(ledPin, HIGH); }
Note that PIN 13 has an LED (also know "L" LED since there is a label "L" next to it) connected on UNO board so we don't need to manually connect another LED. See Arduino.cc website. The first argument 0 is the interrupt number. On an Arduino Uno, interrupt 0 is pin D2 and interrupt 1 is D3. The hardware arrangement is
D2 ---- 1 k resistor --- 5V |--- pushbutton --- Gnd
PWM/Analog Output
Using a multimeter (Sparkfun)
See Chapter 1 of Programming Arduino Next Steps - Analog output. It also teaches how to use multimeter to measure analog output <Sketch_01_07_pwm>. It is noted that UNO does not have true analog output (Arduino Due has). On Arduino UNO board, the pins marked with little "~" (pins 3,5,6,9,10 and 11) can be used as analog outputs (with the analogWrite function).
See Chapter 3 of Programming Arduino Next Steps <Sketch_03_03_1kHz>.
Memory
I2C/TWI
SPI
UART
How UART, SPI, and I2C Serial Communications Work, and Why We Still Use Them
USB Programming
Network Programming
Digital Signal Processing
Relay module shield
- 4 Ways to Control Electronic Relays
- http://www.aliexpress.com/store/product/Four-relay-module4-relay-module-expansion-5V-12V/320981_598692534.html?tracelog=back_to_detail_b
- http://www.glacialwanderer.com/hobbyrobotics/?p=9
- https://www.sparkfun.com/products/10684
- Tutorial http://www.sainsmart.com/8-channel-dc-5v-relay-module-for-arduino-pic-arm-dsp-avr-msp430-ttl-logic.html
- Search amazon for relay module shield. The sellers tend to give connection instructions.
- A relay from SparkFun Inventor Kit. My demo on Youtube. The wiring looks complicated but it actually needs 5 (not 14) wires if we re-organize the wiring.
Transistor
https://learn.sparkfun.com/tutorials/transistors
potentiometer
- Part: https://www.sparkfun.com/products/9806
- Example: SIK guide project 2 (use pot to control the blink rate of LED) from Sparkfun Inventor Kit.
- On potentiometer, number 1 is 5v and number 3 is 0v although we can swap these 2 pins to get reverse effect when using the knob.
- A copy of the SIK guide and example code are available at my github page.
Push button
See how it works at this blog and its references. The diagram below shows the connection (vertically displayed). It is seen legs are already connected in groups of two. When the push button is pressed all the 4 legs are connected. So two components can be A & B (same side) or A & D (opposite side).
A B | | |--/ --| | | C D
Photoresistor
- http://playground.arduino.cc/Learning/PhotoResistor
- https://blog.udemy.com/arduino-ldr/
- analogWrite() documentation says it will map input voltages between 0 and 5 volts into integer values between 0 and 1023.
- Toy Car Speed Trap
A night light example (tested on Arduino Nano)
/* Night light Connect the photoresistor one leg to pin 0, and pin to +5V Connect a resistor (around 10k is a good value, higher Turn on LED if it is dark and turn off LED if it is bright. ---------------------------------------------------- PhotoR 10K +5 o---/\/\/--.--/\/\/---o GND | Anlg Pin 0 o----------- LED Dgt Pin 9 o-----------o GND ---------------------------------------------------- */ int lightPin = 0; //define an analog pin for Photo resistor int ledPin=9; //define a digital pin for LED int threshold = 400; // adjust it according to your need void setup() { Serial.begin(9600); //Begin serial communcation pinMode(lightPin, INPUT); pinMode( ledPin, OUTPUT ); // can be replaced by the built-in small LED // pinMode(LED_BUILTIN, OUTPUT); } void loop() { int v = analogRead(lightPin); Serial.println(v); if ( v < threshold) analogWrite(ledPin, 255); else analogWrite(ledPin, 0); delay(10); //short delay for faster response to light. }
IR resistor
Measure RPM with an IR sensor and Arduino
IR remote
Controlling any IR device with a remote and some hacking
Servo
Trinket
- http://www.adafruit.com/product/1501
- http://makezine.com/2014/12/19/small-but-mighty-meet-adafruit-trinket/
Evermind sensors
- An article from PCworld.
Protoboard
http://makezine.com/2015/10/15/how-and-when-to-use-protoboard/
My Misc Collection
- Transistor TIP 120 from adafruit. Great for whenever you need to control medium to high-power electronics such as motors, solenoids, or 1W+ LED.
- Transistor P2N2222AG from Sparkfun Inventor Kit. Used to control DC motor.
- L298P Motor Shield For Arduino (Ardumoto) from ebay and arduino.cc. An example code to control one or 2 motors is at instructables.com.
- 5V L298N Dual Stepper Motor Driver Controller Board Module includes standoff. Very large about 2inch x 2inch.
- Diode 1N4001 from Sparkfun Inventor Kit. Used to control DC motor.
- 74HC595 Shift Register from Sparkfun Inventor Kit. Used to control more LEDs. See an example from Adafruit.
- Small IR sensor from Adafruit.
- MCP23017 i2c 16 input/output port expander from Adafruit. It can be used to control both LCD and keypad.
- 4-Bit level converter from Adafruit. This is similar to Sparkfun. See also its use in communication between BeagleBone and Arduino.
- Bluefruit EZ-Link from Adafruit.
- Pulse sensor kit from Adafruit.
- H-bridge (SN754410) motor drive 1A from sparkfun. Used to control DC motors.
- Arduino Pro Mini 328 - 3.3V/8MHz from sparkfun.
- JY-MCU bluetooth module from dx.com
- MMA7361 Triple Axis Accelerometer Breakout from dx.com
- ADXL 345 3-Axis Gravity Acceleration Sensor Module from dx.com.
- HC-SR04 Ultrasonic Sensor Distance Measuring Module from dx.com. Example code can be found arduinobasics.blogspot.com/ (nice website including many arduino projects). Unbiased measure but very sensitive. Need only 2 digital pins to measure distance. This is another instruction which includes an LCD to show the distance.
- Arduino ethernet shield.
- Arduino LCD keypad shield from dx.com
- 2-Channel Relay Shield Module for Arduino from dx.com
- USB to uart adapter from dx.com.
- Pololu USB AVR Programmer. Used for my 3pi Robot.
- wiichuck adapter.
- IR Infrared Motion Detection Sensor Module The arduino sketch can be found on instructables.com and arduino.cc.
- V27D-T1 0.56" 3-Digital LED Voltmeter
- Nano V3.0 for Arduino (Atmega328P-AU)
- Adafruit Trinket - Mini 5V
- Adafruit Perma-Proto Half-sized Breadboard
- Potentiometer Knob
- Adafruit 12-Key Capacitive Touch Sensor breakout
- Adafruit Push-button Power Switch Breakout
- Dual H-Bridge Motor Driver for DC or Steppers
- 2.1mm DC Barrel Plug to Alligator Clips
- Adafruit Proto Shield for Arduino Kit
- 4 x AA Battery Holder with On/Off Switch
- 5V 2A (2000mA) switching power supply
- LC XL6009 DC to DC step up power converter (Input voltage: 3~32V; output voltage: 5~35V; input current: 4A max., 18mA (no load)) and the project of solar power personal fan. Other choice is LM2577S module such as this one.
- Sparkfun Simon says
- 1A Lithium Battery Charging Module
- DS3231 High Precision Real-Time Clock Module
- 3-Pin Slide Switch DIY Parts
- Passive Speaker Buzzer Module for Arduino
- SainSmart HDMI/VGA Digital 9 Inch Touch Screen LCD+Driver Board It works on Windows & Linux. See my screenshots and some notes of running on UDoo device on here. The touch screen driver is available for download too though I haven't tested it yet. CF: A similar one but there is no touch screen support and this one but there is no LCD nor the touch functionality.
- ESP8266
- Polymer Lithium Ion Battery - 2000mAh. I also need a Lipo charger like adafruit or sparkfun.
- Slide Pot - Small (10k Linear Taper)
3D
Software
- 123D Design from AUTODESK and an article (The ‘Pi’cture: A 3D Printed Raspberry Pi Camera You Can Build Yourself) mentioned about it.
Embedded System
- Introduction to Embedded Systems: Using ANSI C and the Arduino Development Environment by David Russell (Author), Mitchell Thornton (Series Editor)
- Chapter 3 (Exploring Embedded Linux Systems] of Exploring Beaglebone by Derek Molloy.
Open source hardware
8 ways to get started with open source hardware
Soldering
Seller, Community
- http://arduino.cc/en/Main/Buy
- Arduino.cc forum
- adafruit and Adafruit forum
- Sparkfun
- Parallax Resources and Forum
- Element14 Community
- Newark
The CanaKit's Sparkfun inventor's kit for Arduino (SX10173) contains lots of stuff like 1N4148 diode, P2N222AG NPN transistor (youtube, potentiometer, 5V relay, temperature sensor (TMP36GZ), 74HC595 shift register, hobby servo and photo resistor/photocell. Circ-03 (or Circ-12 on the new guide) teaches how to use P2N222AG transistor and 1N4001 Diode to spin a motor. See the SIK guide in pdf from the above link. The resistors it has included have 330 ohm, 10K. I also purchased 3.3M resistors for another application.
In the Arduino budget pack, it includes 100 ohm, 1k and 10k resistors and photocell.
http://lifehacker.com/how-can-i-get-into-a-new-hobby-without-breaking-the-ban-489189582