2017년 7월 4일 화요일

App Inventor + Led ATmega


Creating app in the inventor app.

Creating app in App Inventor + ATmega32


The programs can be downloaded here:


A module HC-06, ATmega32 and a programmed USBasp were used.



The program sends 3 commands: CMD1, CMD2, and CMD3.

The CMD1 and 2 are sent with an order, 0 or 1, to turn a led on or off.
CMD10 and CMD11 are sent to turn off and on a red led. For the green led CMD20 and CMD21 are sent.
Also the CMD3 is sent accompanied by a number, between 0 and 255, to change the light intensity of a third yellow LED using PWM.

The three commands take a line break at the end (\ n) as the end of the frame.


The final program looks like the following figure:

Brief explanation:
Each time a BTNGreen button is pressed, and if there is a connection to the bluetooth module, the program will send CMD20 or CMD21 according to the variable green_status. The color and text of the button are also changed.



The operations with the BTNRed button are similar to the previous button.



Each time the value of the slide changes, and if the device is connected, the command 3 (CMD3) will be sent with the respective value indicated by the slide. Also displayed in slide value in a text box

When the button to connect is pressed, the device will be disconnected in case it is connected or a list (List) will be displayed with the linked devices (if the device is not linked, it must be done previously) in order to make the connection.



Before showing the list, and only when the bluetooth of our phone is activated, it will be filled with the devices linked to the phone.



Finally, after selecting a device the program will attempt to connect to the HC-06.





Complete program:




댓글 없음:

댓글 쓰기