Difference between revisions of "Arduino and Cake/Big Box"

From Makespace
Jump to: navigation, search
(LEDs and displays)
(LEDs and displays)
Line 93: Line 93:
 
: Dot matrix displays, single colour with drivers
 
: Dot matrix displays, single colour with drivers
  
<span style='font-family: monospace; display: block; margin-left: 10px; margin-right: 10px; margin-top: 10px; margin-bottom: 10px; padding: 6px; border: 1px solid #aaa; font-size: 12px; line-height: 15px;background-color: #f9f9f9;'><span style='color: #7E7E7E;'>/*&nbsp;MAX7219&nbsp;Example&nbsp;</span><br>
+
<span style='font-family: monospace; display: block; margin-left: 10px; margin-right: 10px; margin-top: 10px; margin-bottom: 10px; padding: 6px; border: 1px solid #aaa; font-size: 12px; line-height: 15px;background-color: #f9f9f9;'><span style='color: #7E7E7E;'>/&#42;&nbsp;MAX7219&nbsp;Example&nbsp;</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;Tom&nbsp;Oinn,&nbsp;16th&nbsp;September&nbsp;2013</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;Tom&nbsp;Oinn,&nbsp;16th&nbsp;September&nbsp;2013</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;Drive&nbsp;our&nbsp;dot&nbsp;matrix&nbsp;and&nbsp;7+1&nbsp;segment&nbsp;displays&nbsp;using&nbsp;the&nbsp;LedControl&nbsp;</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;Drive&nbsp;our&nbsp;dot&nbsp;matrix&nbsp;and&nbsp;7+1&nbsp;segment&nbsp;displays&nbsp;using&nbsp;the&nbsp;LedControl&nbsp;</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;library,&nbsp;download&nbsp;from&nbsp;http://playground.arduino.cc/Main/LedControl</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;library,&nbsp;download&nbsp;from&nbsp;http://playground.arduino.cc/Main/LedControl</span><br>
<span style='color: #7E7E7E;'>&nbsp;*/</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;/</span><br>
 
&#35;include&nbsp;&lt;<span style='color: #CC6600;'>LedControl</span>.h&gt;<br>
 
&#35;include&nbsp;&lt;<span style='color: #CC6600;'>LedControl</span>.h&gt;<br>
 
<br>
 
<br>
<span style='color: #7E7E7E;'>/*&nbsp;Digital&nbsp;pin&nbsp;connected&nbsp;to&nbsp;the&nbsp;'DIN'&nbsp;on&nbsp;the&nbsp;module&nbsp;*/</span><br>
+
<span style='color: #7E7E7E;'>/&#42;&nbsp;Digital&nbsp;pin&nbsp;connected&nbsp;to&nbsp;the&nbsp;'DIN'&nbsp;on&nbsp;the&nbsp;module&nbsp;&#42;/</span><br>
 
<span style='color: #CC6600;'>int</span> DATA = 5;<br>
 
<span style='color: #CC6600;'>int</span> DATA = 5;<br>
<span style='color: #7E7E7E;'>/*&nbsp;Digital&nbsp;pin&nbsp;connected&nbsp;to&nbsp;the&nbsp;'CS'&nbsp;on&nbsp;the&nbsp;module&nbsp;*/</span><br>
+
<span style='color: #7E7E7E;'>/&#42;&nbsp;Digital&nbsp;pin&nbsp;connected&nbsp;to&nbsp;the&nbsp;'CS'&nbsp;on&nbsp;the&nbsp;module&nbsp;&#42;/</span><br>
 
<span style='color: #CC6600;'>int</span> CS = 6;<br>
 
<span style='color: #CC6600;'>int</span> CS = 6;<br>
<span style='color: #7E7E7E;'>/*&nbsp;Digital&nbsp;pin&nbsp;connected&nbsp;to&nbsp;the&nbsp;'CLK'&nbsp;on&nbsp;the&nbsp;module&nbsp;*/</span><br>
+
<span style='color: #7E7E7E;'>/&#42;&nbsp;Digital&nbsp;pin&nbsp;connected&nbsp;to&nbsp;the&nbsp;'CLK'&nbsp;on&nbsp;the&nbsp;module&nbsp;&#42;/</span><br>
 
<span style='color: #CC6600;'>int</span> CLOCK = 7;<br>
 
<span style='color: #CC6600;'>int</span> CLOCK = 7;<br>
 
<br>
 
<br>
<span style='color: #7E7E7E;'>/*&nbsp;</span><br>
+
<span style='color: #7E7E7E;'>/&#42;&nbsp;</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;Number&nbsp;of&nbsp;displays&nbsp;connected,&nbsp;more&nbsp;displays&nbsp;can&nbsp;be&nbsp;chained</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;Number&nbsp;of&nbsp;displays&nbsp;connected,&nbsp;more&nbsp;displays&nbsp;can&nbsp;be&nbsp;chained</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;together&nbsp;by&nbsp;connecting&nbsp;the&nbsp;(hopefully)&nbsp;obvious&nbsp;pins.&nbsp;Displays</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;together&nbsp;by&nbsp;connecting&nbsp;the&nbsp;(hopefully)&nbsp;obvious&nbsp;pins.&nbsp;Displays</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;are&nbsp;numbered&nbsp;with&nbsp;display&nbsp;1&nbsp;being&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;chain&nbsp;if</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;are&nbsp;numbered&nbsp;with&nbsp;display&nbsp;1&nbsp;being&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;chain&nbsp;if</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;you&nbsp;have&nbsp;more&nbsp;than&nbsp;one.</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;you&nbsp;have&nbsp;more&nbsp;than&nbsp;one.</span><br>
<span style='color: #7E7E7E;'>&nbsp;*/</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;/</span><br>
 
<span style='color: #CC6600;'>int</span> DISPLAYS = 3;<br>
 
<span style='color: #CC6600;'>int</span> DISPLAYS = 3;<br>
 
<br>
 
<br>
<span style='color: #7E7E7E;'>/*&nbsp;</span><br>
+
<span style='color: #7E7E7E;'>/&#42;&nbsp;</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;Create&nbsp;a&nbsp;new&nbsp;LedControl&nbsp;object,&nbsp;passing&nbsp;in&nbsp;the&nbsp;data,&nbsp;</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;Create&nbsp;a&nbsp;new&nbsp;LedControl&nbsp;object,&nbsp;passing&nbsp;in&nbsp;the&nbsp;data,&nbsp;</span><br>
<span style='color: #7E7E7E;'>&nbsp;*&nbsp;clock,&nbsp;chip&nbsp;select&nbsp;and&nbsp;number&nbsp;of&nbsp;displays&nbsp;</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;&nbsp;clock,&nbsp;chip&nbsp;select&nbsp;and&nbsp;number&nbsp;of&nbsp;displays&nbsp;</span><br>
<span style='color: #7E7E7E;'>&nbsp;*/</span><br>
+
<span style='color: #7E7E7E;'>&nbsp;&#42;/</span><br>
 
<span style='color: #CC6600;'>LedControl</span> lc = <span style='color: #CC6600;'>LedControl</span>(DATA, CLOCK, CS, DISPLAYS);<br>
 
<span style='color: #CC6600;'>LedControl</span> lc = <span style='color: #CC6600;'>LedControl</span>(DATA, CLOCK, CS, DISPLAYS);<br>
 
<br>
 
<br>
 +
<span style='color: #7E7E7E;'>/&#42;&nbsp;Initialise&nbsp;the&nbsp;displays&nbsp;&#42;/</span><br>
 
<span style='color: #CC6600;'>void</span> <span style='color: #CC6600;'><b>setup</b></span>() {<br>
 
<span style='color: #CC6600;'>void</span> <span style='color: #CC6600;'><b>setup</b></span>() {<br>
 
&nbsp;&nbsp;<span style='color: #CC6600;'>for</span> (<span style='color: #CC6600;'>int</span> n = 0; n &lt; DISPLAYS; n++) {<br>
 
&nbsp;&nbsp;<span style='color: #CC6600;'>for</span> (<span style='color: #CC6600;'>int</span> n = 0; n &lt; DISPLAYS; n++) {<br>
Line 129: Line 130:
 
}<br>
 
}<br>
 
<br>
 
<br>
 +
<span style='color: #7E7E7E;'>/&#42;&nbsp;Used&nbsp;to&nbsp;allow&nbsp;the&nbsp;sin&nbsp;wave&nbsp;to&nbsp;animate&nbsp;&#42;/</span><br>
 
<span style='color: #CC6600;'>float</span> offset = 0.0;<br>
 
<span style='color: #CC6600;'>float</span> offset = 0.0;<br>
 
<br>
 
<br>
 
<span style='color: #CC6600;'>void</span> <span style='color: #CC6600;'><b>loop</b></span>() {<br>
 
<span style='color: #CC6600;'>void</span> <span style='color: #CC6600;'><b>loop</b></span>() {<br>
 +
&nbsp;&nbsp;<span style='color: #7E7E7E;'>/&#42; Iterate over the total number of rows, i.e. DISPLAYS &#42; 8 &#42;/</span><br>
 
&nbsp;&nbsp;<span style='color: #CC6600;'>for</span> (<span style='color: #CC6600;'>int</span> i = 0 ; i &lt; DISPLAYS &lt;&lt;3; i++) {<br>
 
&nbsp;&nbsp;<span style='color: #CC6600;'>for</span> (<span style='color: #CC6600;'>int</span> i = 0 ; i &lt; DISPLAYS &lt;&lt;3; i++) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: #CC6600;'>int</span> shift = (<span style='color: #CC6600;'>int</span>)((<span style='color: #CC6600;'>sin</span>(offset + ((<span style='color: #CC6600;'>float</span>)(i)*0.6))+1.0)*4.0);<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: #7E7E7E;'>/&#42; For each row work out where we want the dot for a sin wave &#42;/</span><br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: #CC6600;'>int</span> shift = (<span style='color: #CC6600;'>int</span>)((<span style='color: #CC6600;'>sin</span>(offset + ((<span style='color: #CC6600;'>float</span>)(i)&#42;0.6))+1.0)&#42;4.0);<br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: #7E7E7E;'>/&#42; </span><br>
 +
<span style='color: #7E7E7E;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#42;&nbsp;Set&nbsp;the&nbsp;row&nbsp;to&nbsp;be&nbsp;that&nbsp;value,&nbsp;we'd&nbsp;use&nbsp;columns&nbsp;but&nbsp;our</span><br>
 +
<span style='color: #7E7E7E;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#42;&nbsp;are&nbsp;the&nbsp;wrong&nbsp;shape&nbsp;on&nbsp;the&nbsp;boards&nbsp;to&nbsp;do&nbsp;that.&nbsp;Columns&nbsp;would</span><br>
 +
<span style='color: #7E7E7E;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#42;&nbsp;be&nbsp;more&nbsp;efficient&nbsp;and&nbsp;require&nbsp;fewer&nbsp;shift&nbsp;operations&nbsp;internally</span><br>
 +
<span style='color: #7E7E7E;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#42;/</span><br>
 
&nbsp;&nbsp;&nbsp;&nbsp;lc.setRow(i&gt;&gt;3,&nbsp;i&nbsp;&amp;&nbsp;7,&nbsp;1&lt;&lt;shift);&nbsp;<br>
 
&nbsp;&nbsp;&nbsp;&nbsp;lc.setRow(i&gt;&gt;3,&nbsp;i&nbsp;&amp;&nbsp;7,&nbsp;1&lt;&lt;shift);&nbsp;<br>
 
&nbsp;&nbsp;}<br>
 
&nbsp;&nbsp;}<br>
 +
&nbsp;&nbsp;<span style='color: #7E7E7E;'>/&#42; Increment the offset, add a delay and go around again &#42;/</span><br>
 
&nbsp;&nbsp;offset&nbsp;+=&nbsp;<span style='color: #006699;'>PI</span> / 16;<br>
 
&nbsp;&nbsp;offset&nbsp;+=&nbsp;<span style='color: #006699;'>PI</span> / 16;<br>
 
&nbsp;&nbsp;<span style='color: #CC6600;'>delay</span>(50);<br>
 
&nbsp;&nbsp;<span style='color: #CC6600;'>delay</span>(50);<br>

Revision as of 10:32, 16 September 2013

Big box!

Big Box of Breakout Boards and Bits

We have a box of bits containing Arduinos for use in the space along with an assortment of sensors, motors, lights and other things you might need to make up a project. It lives in... (to be confirmed, currently it lives in my kitchen, obviously that won't be its final location!)

This page exists to catalogue the contents of the box along with any notes on how to use each modules, including links to Arduino libraries, datasheets, photos showing pinouts and suchlike. Basically if you've figured out how to use a module through extensive googling and experimentation here is where you can share that knowledge with everyone else. Use your signatures to claim credit!

Policies

This is not primarily intended to be used as stock for people's projects, rather it's there to provide a lending library of parts for use at events such as the Arduino and Cake sessions and Family Makers. That said, none of the parts are particularly expensive and we try to have a reasonable number of them so if you really need something for a project right now, aren't going to be taking the last one of something and are prepared to provide a replacement in non ludicrous time that's probably fine. If unsure ask on the mailing list! Most things here have been bought from sellers from the far East on eBay, so while they're cheap the lead times are often quite lengthy.

There's a section at the end of this page for requests - if there's something you'd like to have access to and which is of general use (i.e. not for just one project you have in mind) add some details and we'll see whether we can source it at an appropriate price. If something goes wrong and the magic white smoke escapes from something please make a note in the section for the component or module concerned, that way we know it's broken and can either fix or replace it (and tell everyone how to avoid the same thing happening again)

What's in the Box?

Contents of the box, both current and planned. Things that have arrived and are ready for use are marked in this colour. We need photos and documentation for everything on this list!

Spotter's Guide
Max7219matrix.jpg
Max7219 based dot matrix display
Max7219segment.jpg
Max7219 based seven segment LED display
Steppermotor.jpg
5v stepper motor
Steppermotordriver.jpg
Driver board for 5v stepper motor
Nrf24l01.jpg
NRF24L01 radio modules
Irbeambreak.jpg
IR beam break detector
Dht11.jpg
DHT11 temperature / humidity sensor
Barometric.jpg
Barometric pressure sensor
Deadservo.jpg
Geared 6v motor (ex servo)
Bagofleds.jpg
Assorted pink, green, orange and blue LEDs
Mpu6050.jpg
MPU6050 six axis motion sensor
Arduinonano.jpg
Arduino nano v3
Nanoethernet.jpg
Arduino nano ethernet shield
Lcddisplay.jpg
Blue LCD display
9gservo.jpg
9g servo and accessories
Ultrasoundranger.jpg
Ultrasonic rangefinder board
Hbridge.jpg
Dual H-bridge module
Cablesoflurve.jpg
Cables of lurve

Arduinos

6x Arduino Nano v3
Breadboard compatible Arduinos with ATMega328 processors. Note that the 3.3v rail is driven from the FTDI chip (the part that interfaces with USB) so is only available when powered through the USB cable (in other cases use a 3.3v regulator). If supplying external power remember to use the VIn pin and not the 5v one, even if you think you have a regulated power supply.

Sensors and Input Devices

3x DHT11 temperature and humidity Sensors
These modules break out the three usable pins on the DHT11 sensors
MPU6050 based 6 axis motion sensor board
I2C based motion processor, contains a 3 axis gyroscope in conjunction with a 3 axis linear accelerometer and an embedded DSP
1x Barometric pressure sensor board
Not tested yet, but believed to be a BMP085, which if so is capable of resolving pressure differences corresponding to about 20cm of altitude, very nifty!
Ultrasonic rangefinders
Modules with an ultrasonic emitter / receiver pair and the logic to calculate distance to a reflecting object based on timing.

Motors and other Output Devices

12x Dual H-bridge modules, used to drive regular and stepper motors
H-Bridge modules, used to interface to high power devices including motors and drive them from the logic level signals on the Arduino.
1x hacked HiTec HS-625MG
A tough servo with the servo bits removed, now just acts as a high quality electric motor with a gearbox. Drive at 5-6v and use conventional PWM / H-Bridge to alter its speed and direction.
10x 9g servo motors
Basic servo motors. Use the Servo or modified Servo2 library (the latter for when you need to drive more than a couple of servos at a time from the Arduino)
4x 5V stepper motors with driver boards
Document how to make them work here (Martin?) - there's more info on these exact boards along with example code here, yet to be tried but they look identical!

Communications

10x NRF24L01 Radio Modules
Short range radio modules, use the mIRF library. (edit - we've lost one, there are now nine of them....)
2x Arduino nano ethernet shields
Stackable modules providing an ethernet jack

LEDs and displays

High brightness LEDs
20 each of four different colours (pink, green, blue and orange) 5mm LEDs, remember to use current limiting resistors or a constant current source when driving them!
4x LED Dot matrix modules with drivers
Dot matrix displays, single colour with drivers

/* MAX7219 Example 
 * Tom Oinn, 16th September 2013
 * Drive our dot matrix and 7+1 segment displays using the LedControl 
 * library, download from http://playground.arduino.cc/Main/LedControl
 */
#include <LedControl.h>

/* Digital pin connected to the 'DIN' on the module */
int DATA = 5;
/* Digital pin connected to the 'CS' on the module */
int CS = 6;
/* Digital pin connected to the 'CLK' on the module */
int CLOCK = 7;

/* 
 * Number of displays connected, more displays can be chained
 * together by connecting the (hopefully) obvious pins. Displays
 * are numbered with display 1 being at the end of the chain if
 * you have more than one.
 */
int DISPLAYS = 3;

/* 
 * Create a new LedControl object, passing in the data, 
 * clock, chip select and number of displays 
 */
LedControl lc = LedControl(DATA, CLOCK, CS, DISPLAYS);

/* Initialise the displays */
void setup() {
  for (int n = 0; n < DISPLAYS; n++) {
    lc.shutdown(n,false);
    lc.setIntensity(n,8);
    lc.clearDisplay(n);
  }
}

/* Used to allow the sin wave to animate */
float offset = 0.0;

void loop() {
  /* Iterate over the total number of rows, i.e. DISPLAYS * 8 */
  for (int i = 0 ; i < DISPLAYS <<3; i++) {
    /* For each row work out where we want the dot for a sin wave */
    int shift = (int)((sin(offset + ((float)(i)*0.6))+1.0)*4.0);
    /*
     * Set the row to be that value, we'd use columns but our
     * are the wrong shape on the boards to do that. Columns would
     * be more efficient and require fewer shift operations internally
     */
    lc.setRow(i>>3, i & 7, 1<<shift); 
  }
  /* Increment the offset, add a delay and go around again */
  offset += PI / 16;
  delay(50);
}

2x Eight digit seven segment displays with drivers
Standard 'calculator style' seven segment displays in a module of eight of them with associated driver circuitry.
4x LCD 20x4 character displays
LCD character displays, serial protocol (probably!) to drive them.

Everything else

2x IR correlation modules
IR beam break sensors with amplifiers to provide a clean signal. Not tested yet!
10x Playstation style joysticks
Analogue joysticks with an embedded press button
Male to male and male to female jumper leads
A load of long jump leads with pins and sockets (depending on type) to make it easier to interface to modules such as the NRF24L which have otherwise awkward pin layouts and can't be directly connected to a breadboard. Update - these are now here, and are so full of lurve that they're unsafe to use unless you are singing 'The Power of Love' by Huey Lewis and the News while doing so. This will be enforced.

Requests

Put your requests for parts here...

At the moment I think we could do with some regular DC motors, some switches, potentiometers, piezo speakers and battery packs (ideally with a few regulator boards capable of providing clean 3.3v, 5v and possibly 12v feeds from the same). We can make the boards, potentially. Even better for power would be a few LiPo packs, again with regulators and suitable chargers.