WII NUNCHUCK projects with Arduino Leonardo AVR-T32U4

Image

https://www.olimex.com/Products/Modules/Sensors/MOD-WII/MOD-Wii-UEXT-NUNCHUCK/ 

WII NUNCHUCK is low cost joystick and 3 axes accelerometer combo which could be read by I2C.

We created UEXT plug-in board which allow WII-NUNCHUCK to be used with any of our development boards with UEXT connector.

Here on this video: http://www.youtube.com/watch?v=fXa6AA9Aq_o

you can see four projects made with WII-NUNCHUCK

1. Mouse – you can move the mouse pointer with Joystick and to use the two buttons as mouse buttons

2. Sound – with the 3 axes accelerometer you can change the pitch of the generated tone

3. Driving two servos with the 3-axes accelerometer

4. Drivinig RGB stripe with MOD-RGB and MOD-WII-NUNCHUCK – as AVR-T32U4 have just one UEXT port we use the UEXTx5 extender.

The demo code is at GitHub: https://github.com/OLIMEX/DUINO/tree/master/AVR/WII-NUNCHUCK

New Product: MOD-LED8x8RGB stackable RGB LED MATRIX

Image

MOD-LED8x8RGB is intelligent 8×8 RGB LED module, it allow many modules to be stacked together.

Image

If we look at the back side there are two connectors named EXT-IN and EXT-OUT when two modules are stack together EXT-IN of the one snap to EXT-OUT of the other so both get connected.

MOD-LED8x8RGB works with 5V power supply as you can see on the two sides there are big copper pads named VCC/GND and VCC1/GND1 when modules are snap together permanently (if you make big screen) is good these VCC-VCC1 and GND-GND1 to be connected between the modules so better power distribution is achieved.

Image

to connect MOD-LED8x8RGB you will need ARDUINO working with 5V like OLIMEXINO-32U4 – make sure the power jumper is set to 5V as OLIMEXINO-32U4 can work both on 3.3 and 5V.

Then you should connect OLIMEXINO-32U4 to MOD-LED8x8RGB as on above picture in this way:

  • D13 -> EXT-IN.LATCH
  • 5V -> EXT-IN.VCC
  • GND -> EXT-IN.GND
  • UEXT.MOSI -> EXT-IN.DATA
  • UEXT.CLK -> EXT-IN.SCK

All next MOD-LED8x8RGB modules snap together, if you make new row of modules use jumper wires to connect EXT-OUT of the most right module on the first row to the EXT-IN of the most left module in the next row and etc.

Working with Arduino led8x8rgb.h library:

led8x8rgb.h and font.h are necessary to work with MOD-LED8x8RGB, you can download them from GitHub: https://github.com/OLIMEX/DUINO/tree/master/AVR/MOD-LED8x8RGB

how to use it?

first define how many matrixes you have connected by altering bigX and bigY numbers in led8x8rgb.h

then you can use color variable to set your color from 0 – black to 7- white

there are two other variables cX and cY which define where on screen to print text or characters and these get automatically updated after printing to new position

the library have functions available:

  • drawPixel(x,y) draws drawPixel at X,Y coordinates (1,1) is upper left corner
  • drawLine(x1,y1,x2,y2) draws line
  • drawRectangle(x1,y1,x2,y2) draws rectangle
  • drawSolidRectangle(x1,y1,x2,y2) draws solid rectangle
  • drawElipse(x,y,rx,ry) draws elipse
  • drawCircle(x,y,r) draws circle
  • drawTriangle(x1,y1,x2,y2,x3,y3) draws triangle
  • drawChar(c) – draws char at cX, cY and updates cX, cY
  • drawString(s) – draws string at cX, cY and updates cX, cY
  • lScroll() – scrolls all screen left 1 column
  • rScroll() – scrolls all screen right 1 column
  • scrollCharLeft(c) – scrolls one character from the bottom right matrix to the left
  • scrollCharRight(c) – scrolls one character from the upper left matrix to the right
  • scrollString( s, dir) – scrolls string left or right depend on dir

Restless_Dancer.ino, Sentence.ino and Winking_Face.ino are demo codes made with led8x8rgb.h library.

Note that MOD-LED8x8RGB is not simple shift register matrix, but have microcontroller inside, so once you shift the info IN and LATCH it the microcontroller takes care to refresh the image on the matrix, this way with slow SPI you can drive large displays as no need to permanently shift new and new images to the screen as on the dummy RGB matrixes.

Here is video of the demo code from the GitHUb:

http://www.youtube.com/watch?v=EImDHxnk6Pw

AVR-T32U4 Arduino Leonardo interfacing to LEDs and Buttons in LED game

Image

We create small video tutorial http://www.youtube.com/watch?v=OCd_YFYHWnM how to connect LEDs and Buttons to AVR-T32U4 Arduino Leonardo and create small Game.

The code is on GitHub https://github.com/OLIMEX/DUINO

A10S-OLinuXino ANDROID GPIO control LED toggle app

Image

We got lot of requests on our forum how to control GPIOs from Android.

With the new A10S Android image we decided to play a bit and it appear to be not hard to implement.

We found two ways to do GPIO control running Android.

GPIO using ADB

1. Boot android (from nand or sdcard)

2. Connect USB-to-Serial cable on UART1

3. Open terminal at speed 115200

4. When loading is ready in the terminal type “sh” and enter

5. “ls /sys/class/gpio_sw” will give you a list of all accessable GPIOs.

The GPIOs name is according to the chip ports. For example PE3 is LED1.

6. To set PE3 as output:

#echo 1 > /sys/class/gpio_sw/PE3/mul_sel

or as input

#echo 0 > /sys/class/gpio_sw/PE3/mul_sel

7. To turn on LED:

#echo 1 > /sys/class/gpio_sw/PE3/data

and to turn off:

#echo 0 > /sys/class/gpio_sw/PE3/data

8. If GPIO is as input to read state:

#cat /sys/class/gpio_sw/PE3/data

GPIO using Android SDK

Basicly you should read and write to the filesys. Make sure that your app is running as root, or else nothing will happen.

The demo program toggle LED1 on every button press.  The sources are at GitHub: https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/A10S/A10S-ANDROID-GPIO

All read/write methods are realized in GPIO.java file.

The application is with single button and each time you press it it toggles the green LED on the board.

TOGGLE

You can see ToggleLED.apk running at this video: http://www.youtube.com/watch?v=8kTUkJx2TgQ

Arduino Breadboarding with AVR-T32U4

Image

AVR-T32U4 is the easiest way to do breadboard projects with Arduino. With retail price of EUR 12.95 this is also the Arduino board with best price/performance ratio.

As you see from the picture above AVR-T32U4 snap perfectly to Breadboard-1 and it powers the two power buses with 3.3V and GND and you have access to all Arduino pins A0-A5 and D0-D13 on the breadboard area, so you can easily connect to LEDs, Servo Motors,  Sensors etc.

Here is step by step instructions what you have to do to get started.

1. Download Arduino IDE from http://arduino.cc/en/Main/Software; Unpack the downloaded zip file in main drive C:\arduino-1.0.4

2. Plug AVR-T32U4 to your PC and it will ask for drivers, point it to C:\arduino-1.0.4\drivers

3. After the drivers are installed run C:\arduino-1.0.4\arduino.exe

4. Select the board to be Arduino-Leonardo as per attached picture

Image

5. Right mouse click on “My computer” then select Properties-> Hardware-> Device Manager and check which virtual COM port is created when you plug AVR-T32U4.

Image

as you see on the picture in this case COM33 is created by Arduino-Leonardo

6. From Arduino menu select the com port as per attached picture:

Image

6. Open Blink LED project:

Image

7. Upload the sketch by click on -> button

Connect LED with longer led to D13 and shorter leg via 220 ohm to GND.

You should see the LED blinking as on this video: http://www.youtube.com/watch?v=M0cVerSNUDc

Congratulations you just complete your first Arduino project!

We also highly recommend you when you do prototype work to put USB-ISO between your Arduino and PC in this case even if you do some stupid like to make short on your Arduino board or put wrong voltage somewhere your PC will be always protected, so even if your Arduino board burn your computer will be safe.

MOD-RGB – Arduino, Maple and Pinguino Examples

Image

Here we will demoнstrate you how to use our new MOD-RGB LED driver UEXT module with our Arduino, Pinguino and Maple boards which have UEXT connector.

Getting the Libraries and Examples

The library/example .zip files for Arduino, Maple and Pinguino can be downloaded from:
https://www.olimex.com/Products/Modules/LED/MOD-RGB/

Installing the Libraries and examples

For Arduino, use the Fade sketch directly, no additional files or configuration needed.

For Maple:
1. Make sure that the Maple IDE is not running
2. Copy the MODRGB folder to the /libraries folder of your Maple IDE installation folder
3. Start the IDE. The “MODRGB” examples should now appear under File/examples.
4. Include the library in your projects as such:
#include “MODRGB.h”

For Pinguino, use the example directly. It has been tested with PIC32-PINGUINO, PIC32-PINGUINO-OTG, PIC32-PINGUINO-MICRO, PIC32-PINGUINO-MX220

 Examples

All packages include the same example – Fade.

It uses built-in functons or the MODRGB library to set the RED, GREEN and BLUE values that the MOD-RGB board outputs.

The example fades the lights from blue to red to green to blue again in an endless loop.
If you want to adjust the speed at which the colors change, change the value of the delay period to your liking:
#define SPEED 500

ImageImageImage

A13-OLinuXino serving MOD-RGB and WEB-CAM for live stream

Image

In the previous post I wrote how A13-OLinuXino runs Apache server and you can control MOD-RGB strip over the internet, now the A13-OLinuXino service is available online at : http://94.156.100.85:8081/RGB/ you can open this URL and see actually web pages served by A13-OLinuXino

What’s new Dimitar Gmishev did is to connect USB web camera to A13-OLinuXino too, so now you can see the RGB stripe response to the web cntrol.

To see the MOD-RGB stripe via the web cam you need video player – in our case this is open source Kantaris player with Ctrl-B you force it to play stream from internet URL and point it to : http://94.156.100.85:8080 and you will see the web cam video stream, so when you change the RGB color control you see the result on the camera!

Have fun and try it yourself

A13-OLinuXino web server with MOD-RGB controlling RGB LED stripe over internet

Image

A13-OLinuXino have enough power to run real apache web server with php5, java script etc like any desktop linux computer.

With MOD-RGB connected to A13-OLinuXino UEXT you can control RGB LED stripe up to 5A per channel over fancy web interface from any device with web browser like your tablet or phone.

For instance you can make cool RGB LED lighting in your home and to control then with your phone, A13-OLinuXino can connect to many different MOD-RGB controllers as they are addressable, so you can connect many LED stripes to A13-OLinuXino web server and to controll them separately.

These are step by step instructions how to duplicate yourself:

Prepare A13-OLinuXino-WIFI for web serving:

Update repository
$apt-get update

Install apache and php
$apt-get install apache2 php5 libapache2-mod-php5

Open browser and type A13 board internal network IP address. For instance http://192.168.0.30 . You should get message “It Works”

Extract demo files into apache dir. For example /var/www/RGB

Compile i2c-tool
$gcc i2c-tool

Make executable
$chmod 777 a.out

Change permitions of i2c-bus
$chmod 777 /dev/i2c*

Now open index.html. You should see color picker. Move mouse. Enjoy :)

FRIDAY FREE BOARD QUIZ ISSUE #28 IS MOD-RGB

Image

MOD-RGB is our new 3 channel RGB LED controller. Each channel can control 12V 5A LEDs so it’s suitable to control high power LEDs and RGB LED stripes.

MOD-RGB directly connects to UEXT on A13-OLinuXino, iMX233-OLinuXino, OLIMEXINO-328 Ardino like, DUINOMITE(-MINI-MEGA-eMEGA), PINGUINO, OLIMEXINO-STM32(MAPLE) and we have demo codes for all these boards. With the help of RPI-UEXT it can be connected to Raspberry Pi also or Stellaris launchpad via STELLARIS-UEXT.

On top of I2C RGB control you can use MOD-RGB as Disco Light controller when you feed Audio singal to the audio connector the R, G and B channel will blink with the low-mid-high frequencies beat.

There is provision MOD-RGB to become DMX controller with MOD-RS485 connected to the UEXT connector, but the firmware is not complete to support DMX yet.

Today at 17.00 o’clock our local Bulgarian time (GMT+2) we will post on Twitter our questions.

You have one hour to reply to our tweet with the correct answer.

At 18.00 o’clock we will count the correct answers and ask random.org to generate random number in range then announce the winner and ship the board by airmail in Monday.

Good Luck!

Blinking LED with Linux or Hello World with iMX233-OLINUXINO

Image

Today I did my first Linux shell script with iMX233-OLinuXino. I used to use Windows for many years, then recently moved to Ubuntu but never had to deal with shell scripting till now.

We should make GPIO testing bench to do functional test of the iMX233-OLinuXino GPIO ports, so I had to learn some new stuff.

Raivis installed so called SYSFS package in the OLinuXino Linux kernel which allow you to access the GPIOs from the linux shell so I had to read some more about Linux shell scripting to may make the board GPIO tester.

After reading about SYSFS it seems pretty easy to manipulate the GPIOs from the shell.

To make GPIO1 output and set in “1” for instance this should be executed:

echo out > /sys/class/gpio/gpio1/direction
echo 1 > /sys/class/gpio/gpio1/value

and to make GPIO2 as input and read it could be done with this script:

echo in > /sys/class/gpio/gpio2/direction
echo cat /sys/class/gpio/gpio2/value

echo will return 0 or 1 depend on GPIO2 state

All gpios can be seen with

$ ls /sys/class/gpio

So my first thing was to attach LED to PIN9 (CONNECTOR.PIN19) which correspondents to gpio0 in Linux (yes I know it’s confusing, there is one cross table and Linux kernel assign the numbers not exactly as per our schematic :-o )

Then run VI and created my first linux script:

echo out > /sys/class/gpio/gpio0/direction
while [ 1 -eq 1 ]
do
echo 1 > /sys/class/gpio/gpio0/value
sleep 1
echo 0 > /sys/class/gpio/gpio0/value
sleep 1
done

saved it as “gpio” and made it executable with

$chmod +x gpio

then executed the script with:

$./gpio

as expected the LED start blinking with 1Hz which you can see on the video: http://youtu.be/4FvNwmmj_X8

Previous Older Entries

Follow

Get every new post delivered to your Inbox.

Join 510 other followers