Introduction
A Bluetooth Low Energy / Internet connected light can be used for all sorts of things. As a status indicator or night light, it could be used to let you know when something has occured. With Arduino101, this can combined with Blynk application so the colors of the NeoPixel ring can be control with ease. The whole project is build using the Ada language with the main highlight to be BLE and Neopixel library in Ada using the C++ library as preference and resource.
Schematic
The main microcontroller for this project is the Arduino 101 because it included a BLE chip which will allowed wireless communication and controlled.
A Photoresistor is added to the project to allowed automation of lighting during the night. One end of the Photoresistor is connected to 5V and the other end is connected to a 10k Ohm resistor that is connected to GND. This create a voltage divider circuit which allowed measurement of the voltage drop on the resistor, and from that value tell the system the amount of light the Photoresistor receives. The junction between the resistor and Photoresistor is connected to the Analog pin A0 on the Arduino 101
The Neopixel Ring is used as a source of lighting for this project because of the ranged of color that is able to provide. The PWR pin on Neopixel is need to be connected to the 5V pin on the Arduino 101 and GND pin simply go to the Arduino's GND pin. Finally, the Data in pin is connected to the Digital pin 6 on the Arduino.
Using Arduino on Ada
AdaCore, the company maintaining GNAT compiler recently released cross compiler version of GNAT for AVR. All tools are cross-platform, if binaries are not available they can be compiled to run on any platform as sources are attainable to download. You can get the GNAT compiler to compile Ada for Arduino.
To start writing embedded code in Ada, several software packages are required:
- GNAT AVR
- AdaCore GPS (part of GNAT AVR package)
- WinAVR GNU gcc tools and libraries for AVR
- Atmel AVR Studio 5 (Only for device XML description file)
GPS (GNAT Programming Studio) is an editor maintained by AdaCore and it's default editor for software written in Ada. If makefile is present it is easy to use it to develop embedded software in Ada.
- Select
Build→Settings→Targets
- Select
Run→Run Main
and changeTarget model
tomake
- Select
Clean→Clean All
and changeTarget model
tomake
- Assure that command in text box is
make clean
- Select
Project→Build *
and changeTarget model
tomake
- Assure that command in text box is
make all
- Now code can be generated and run just like in any other Ada project.
When all required files and tools are installed, machine code can be compiled using avr-gnatmake
tool. It's handy to keep compilation and programming scripts in makefile and invoke them using make
.
Sample makefile for ATmega328P is:
all: main.hex main.lss sizedummy
program:
avrdude -pm8 <PROGRAMMER SPECIFIC> -Uflash:w:"main.hex"
main.elf: force
avr-gnatmake main -o $@ -Os -mmcu=avr4 --RTS=zfp -largs crtm8._o -nostdlib -lgcc -mavr4 -Tdata=0x00800200
main.lss: main.elf
-avr-objdump -h -S main.elf >"main.lss"
main.hex: main.elf
avr-objcopy -O ihex $< $@
sizedummy: main.elf
-avr-size --format=avr --mcu=atmega8 main.elf
clean:
$(RM) *.o leds *.ihex *.ali *.elf *.hex *.lss *.map
Main Software.
Comments