Analog Joystick

Connect an analog joystick to an Arduino. Read two analog values (x- and y-position) and a switch using a method witch does not hog the processor during the whole ADConversion.

The capacitor reduces digital noise on the analog readings.
Joystick

Code

MAX7219 LED driver and 12088 8×8 LED matrix

The 8×8 LED matrix is 64 LEDs arranged in an 8 row, 8 column matrix, just like a chess board.

The Max7219 is used to control 64 LEDs at once. The Arduino sends data to the 7219 using the SPI serial communication protocol. You can have multiple SPI devices connected to an Arduino simultaneously.

For your convenience, the Arduino uses a library to talk to the LED driver. The library takes care of the SPI communication and may also have methods for writing characters or scrolling images. There are a number of Arduino libraries for MAX7219. I happened to chose LedControl.

Download the latest version of LedControl here (I used v1.0.1): https://github.com/wayoda/LedControl/releases

In-depth about the LedControl library, and a bit about the hardware. You don’t have to read it to follow the instructions in this article, but I scavenged a lot of info here: http://playground.arduino.cc/Main/LedControl

The hard part is to figure out the pin configuration of the 12088A/B LED matrix, and how to connect it to the 7219. So here are some images to help you out.

MAX7219 and 12088 LED-matrix

 

MAX7219->LED8x8_12088_02

 

IMG_7156_8x8_LED_matrix_01

Light sensor, LDR

The light sensor is also called a light-dependent resistor (LDR) or photocell. It is connected to Arduino pin A0. analogRead measures the voltage at the pin. You will get a value between 0 and 1023 (where 0 equals ground and 1023 equals +5 volts).

Changing the type of lamps and ambient light will give a bit of variation in your readings. In many cases a covered sensor equals about 500 and an exposed sensor is around 800. So under those circumstances an ON / OFF threshold-value of about 700 would be fine.

 

 

Light sensor


 

 

Code

Read a pot, control 5 LEDs

The pot controls which LED is turned on. The pot is connected to Arduino pin A0. analogRead is used to measure the voltage at A0.

You will get a value between 0 and 1023 (where 0 equals ground and 1023 equals +5 volts).  The analog range is divided into 5 sections (1023 / 5).

Five LEDs are connected to the digital pins 2, 3, 4, 7 and 8. Use a switch statement to address individual pins depending on pot rotation.

Use a small delay to let the circuitry rest before doing the subsequent read, or the value can be erroneous.

Connect a Potentiometer

 

5 LEDs to individual pins

Code

Read a pot, print to Serial Monitor

The USB connection is used for serial communication between Arduino and computer.

The potentiometer pin 2 is connected to Arduino pin A0. analogRead is then used to measure the voltage at the pin. (The potentiometer rating doesn’t matter, but avoid lower resistances than 5k, so you don’t get an uneconomically high current flow.) You will get a value between 0 and 1023 (where 0 equals ground and 1023 equals +5 volts).

Use a small delay to let the circuitry rest before doing the subsequent read, or the value can be erroneous.

Code

12 volt Solenoid or Motor

Use a 12 volt solenoid or motor. Connect a 12 volt power adapter to the Arduino board. On the board there is a pin called Vin that will provide the 12 volts directly from the power adapter. Use Vin to power the solenoid / motor.

There will be a lot of current flowing through the solenoid. If the flow keeps on too long, the solenoid will get very hot. The on-time will probably needs to be shorter than a second.

The term duty cycle means the relation between on-time and off-time. Generally the duty cycle has to be less than 50% if the solenoid shall be turned on and off repeatedly.

Solenoid

IMG_7142_solenoid_01

Code

 

Blink LED

Limit the current flow through the LED with a small resistor R1, ca 200~1000Ω. Otherwise the LED will burn.

The LED can be connected in a few ways.
• Either the Arduino pin (pin 13 in this case) SOURCES 5v to the LED: the LED’s + pin is connected to the Arduino pin. The LED’s – pin is connected to GND.
• Or the Arduino pin SINKS the circuit through the LED. The LED’s + pin is connected to +5 volt supply. The LED’s – pin is connected to Arduino pin 13.

Code