Tag Archives: LED

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

Tagged , , , ,

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.

Tagged , , , ,

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

Tagged , , , , , ,

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

Tagged , , , , ,

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 :)

Tagged , , , ,

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!

Tagged , , , , ,

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

Tagged , , , ,

DuinoMite Project: Using LED as light sensor

Image

Everybody knows that LEDs emit light when you apply voltage on them and current flows through them.

Not everybody knows that LEDs do the reversal too, when the LED is irradiated with light they generate voltage.The more bright is the LED the more voltage it generates.

I made small setup to prove this. First you need high-brigthness LED – I got 8000 mCd red LED and connect the cathode to GND and anode to PIN(1) of DuinoMite as on the picture above.

Then wrote this small code:

10 SETPIN 1,1 ‘setup PIN(1) as analog input
20 A = 0 ‘accumulator variable
30 FOR I = 1 TO 5000 ‘do 5000 times
40 A = A + PIN(1) ‘add the PIN(1) readings to Accumulator i.e. I amplify 5000 times the PIN(1) readings this way
50 NEXT I
60 PRINT A ‘print the result
70 GOTO 20

The 5000 loop is also good to not scroll so fast the print results :)

With not irradiated LED the readings are:

> run
192.255
191.203
189.911
185.656
182.666
182.564
182.943
181.974

If I point it to the red power LED on DuinoMite it reads:
> run
753.331
754.28
748.254
737.647
735.11
736.412

If I point to the yellow LED on Duinomite it reads:
> run
637.537
645.048
647.244
649.502
654.08
651.53
653.978

The RED and YELLOW LEDs are with same brightness, then why the readings are different?

The “sensor” LED is most sensitive to the light spectrum it emmits, so when irradiated with RED light it generate more voltage than when irradiated with YELLOW light.

Tomorrow using this feature I will tell you how to teach DuinoMite to recognize colors, using RED, GREEN, BLUE and WHITE LEDs I will build Color-meter and when irradiate the “sensors” with different color light DuinoMite will recognize it and print on the screen.

Now let’s go back to RED only leds and think what else we can do with them. What If I make row of LEDs and scan them sequentially? I will make some low resolution (5 mm dot) scanner.

I make next setup with 4 LEDs wired as “sensors”:

Image

The code nave to be changed to scan for 4 analog inputs:

10 NBR = 100 ‘how much to amplify
20 OPTION BASE 1 ‘option base for the arrays 
30 DIM P(4)
40 FOR I = 1 TO 4: SETPIN I,1: NEXT ‘make PIN1-4 as analog inputs
50 CLS
60 FOR I = 1 TO 4: P(I) = 0: NEXT ‘clear the accumulators
70 FOR I = 1 TO NBR ‘read the analog inputs NBR times and add to the accumulators
80 FOR J = 1 TO 4
90 P(J) = P(J) + PIN(J)
100 NEXT J
110 NEXT I
120 FOR I = 1 TO 4 ‘display as graphics bars on the Duinomite VGA screen
130 LINE (I*30,MM.VRES)-(I*30+25,MM.VRES-2*P(I)),1,BF
140 NEXT I
145 PAUSE 200 ‘wait and do it again
150 GOTO 50

When run I can see bar graph which change with the amount of light which fall on the LEDs.

You can see on this video I apply light on the LEDs with RED high intenity LED of same kind, and this generates a lot of response on the “sensor” LEDs.

The same principle is used in this video, it uses 8×8 LED matrix as multi touch touchscreen device, too bad I have no 8 Analog inputs on DuinoMite as if I had I would duplicate this project :-)

Similar projects are also THIS and THIS

You could even make on the same principle Interractive LED table like THIS

Tagged , , ,

DUINOMITE: TESTING NEW COMMANDS SHIFTOUT

Image

These who used Basic stamps in the past remember how useful were the SHIFTIN and SHIFTOUT commands to send and receive serial data. These commands were missing in DM-BASIC  and I was wondering how to interface our new MOD-LED8X8 stackable LED bricks. Using normal BASIC commands which execute for 32 uS each would make the output very slow, so I wrote on KSD forum – I need desperately SHIFTIN/SHFTOUT commands :) .

Ken is busy right now with the USB host implemetation so Keyboards, Mouses and USB memory sticks to be implemeted in DM-BASIC so I was not expecting that he will have time soon to work on this, but for my nice surprise Iggy from the forum said I will try to implement this over the evening.

Today he sent me DuinoMite.HEX with SHIFTOUT command with this syntax:

SHIFTOUT DataPin, ClockPin, Mode, STRING$, numebr-of-bits-to-be-sent

I immediately wired the MOD-LCD8x8 and wrote this small piece of code:

 

10 DP =1: CP = 2: LP=3 ‘define data, clock and latch pins
20 SETPIN DP,8: SETPIN CP,8: SETPIN LP,8 ‘make them outputs
30 A$ = CHR$(&h55)+CHR$(&h55)+CHR$(&h55) ‘ 10101010 10101010 101010
35 B$ = CHR$(&hAA)+CHR$(&HAA)+CHR$(&HAA) ’01010101 01010101 01010101
40 SHIFTOUT DP,CP,0,A$,24 ‘send first pattern
50 PIN(LP)=1: PIN(LP)=0 ‘latch to display it
60 PAUSE 100 ‘wait a little bit
70 SHIFTOUT DP,CP,0,B$,24 ‘sent second pattern
80 PIN(LP)=1: PIN(LP)=0 ‘latch to display it
90 PAUSE 100 ‘wait a little bit 
100 GOTO 40

as expected everything was working and I got nice blinking pattern on my LED-matrix

The great thing with MOD-LED8x8 is that I can stack them together to make any size LED display.

SHIFTOUT now works up to 235Khz so it also can be used to generate nice frequency digital patterns on any DuinoMite PIN.

Well done Iggy! Now Ken have just to include this code in the DuinoMite main firmware. 

THIS IS THE POWER OF THE OPEN SOURCE!

the SHIFTIN code is also being prepared, and I have nice project with SHIFTIN command use in mind ;)

 

Tagged , , , ,
Follow

Get every new post delivered to your Inbox.

Join 219 other followers