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:




flashlight with the flash of the camera


as I can make a program in App Inventor to handle the camera flash as a flashlight

--
Developers cannot use the camera flash as a flashlight using App Inventor programming.  Not possible.

Perhaps, try something like this if you want a kind of flashlight app?:
You need a button, a Canvas (with dimensions about 320 x 400 pixels) and some imagination. Clicking the Turn on button makes the screen bright.  Click again and the device screen goes dark.

--

Arduino101Moisture


The Arduino 101 Moisture Sensor lets users receive data from a moisture sensor attached to the Arduino, however it can be used for any similar device that provides a linear analog signal based on some external phenomenon.
More Links
⦁ Download a sample project for the Arduino 101 Moisture Sensor.
⦁ View the how to instructions for the Arduino 101 Moisture Sensor.

Properties

⦁ BluetoothDevice – The BluetoothLE component with a connection to the Arduino 101.

get Arduino101Moisture1 BluetoothDevice
set Arduino101Moisture1 BluetoothDevice  to
⦁ Pin – The Pin on the Arduino board that the device is wired in to.
get Arduino101Moisture1 Pin
set Arduino101Moisture1 Pin  to

Methods

⦁ IsSupported – Tests whether the Bluetooth low energy device is broadcasting support for the service. If true, calls to TurnOn and TurnOff should work correctly. Otherwise an error will be reported through the Screen's ErrorOccurred event.

call Arduino101Moisture1 IsSupported
⦁ ReadMoisture – Obtain the most recent reading from the moisture sensor as reported by the Arduino. On success, the MoistureReceived event will be run.
call Arduino101Moisture1 ReadMoisture
⦁ RequestMoistureUpdates – Request notification of updates for the moisture sensor attached to the Arduino 101. The MoistureReceived event will be run as moisture sensor readings are received from the Arduino.
call Arduino101Moisture1 RequestMoistureUpdates
⦁ StopMoistureUpdates – Stop listening for notifications of moisture sensor readings from the ARduino. This only has an effect if there was a previous call to RequestMoistureUpdates. There may be additional pending messages that will be processed after this call.
call Arduino101Moisture1 StopMoistureUpdates

Events

⦁ MoistureReceived – The MoistureReceived event is run when a moisture measurement is received from the moisture sensor attached to the Arduino 101.

   Parameters:
   ⚬ moisture (number) — The moisture level measured, between 0 and 100.

when Arduino101Moisture1 MoistureReceived moisture do


Arduino101LightSensor


The Arduino 101 Light Sensor component lets users receive data from a light sensor attached to the Arduino, however it can be used for any similar device that provides a linear analog signal based on some external phenomenon.
More Links
⦁ Download a sample project
⦁ View the how to instructions for the Arduino 101 Light Sensor.

Properties

⦁ BluetoothDevice – The BluetoothLE component with a connection to the Arduino 101.

get Arduino101LightSensor1 BluetoothDevice
set Arduino101LightSensor1 BluetoothDevice  to
⦁ Pin – The Pin on the Arduino board that the device is wired in to.
get Arduino101LightSensor1 Pin
set Arduino101LightSensor1 Pin  to

Methods

⦁ IsSupported – Tests whether the Bluetooth low energy device is broadcasting support for the service. If true, calls to TurnOn and TurnOff should work correctly. Otherwise an error will be reported through the Screen's ErrorOccurred event.

call Arduino101LightSensor1 IsSupported
⦁ ReadLightSensor – Obtain the most recent reading from the light sensor as reported by the Arduino. On success, the LightSensorDataReceived event will be run.
call Arduino101LightSensor1 ReadLightSensor
⦁ RequestLightSensorUpdates – Request notification of updates for the light sensor attached to the Arduino 101. The LightSensorDataReceived event will be run as light sensor readings are received from the Arduino.
call Arduino101LightSensor1 RequestLightSensorUpdates
⦁ StopLightSensorUpdates – Stop listening for notifications of light sensor readings from the Arduino. This only has an effect if there was a previous call to RequestLightSensorUpdates. There may be additional pending messages that will be processed after this call.
call Arduino101LightSensor1 StopLightSensorUpdates

Events

⦁ LightSensorDataReceived – The LightSensorDataReceived event is run when a sample is received from the light sensor attached to the Arduino 101.

   Parameters:
  ⬦ intensity (number) — The intensity of the light received from the sensor, linear in the voltage provided by the light sensor.

when Arduino101LightSensor1 LightSensorDataReceived intensity do


Arduino101Led


The Arduino LED component lets users control light-emitting diodes (LEDs) from their App Inventor projects. If the LED is plugged into a pin supporting pulse width modulation (PWM), then the LED's brightness can be controlled by varying the Intensity property. TurnOn and TurnOff methods are used to control the power state of the LED.
More Links:
⦁ Download a sample project for the Arduino 101 LED.
⦁ View the how to instructions for the Arduino 101 LED.

Properties

⦁ BluetoothDevice – The BluetoothLE component with a connection to the Arduino 101.

get Arduino101Led1 BluetoothDevice
set Arduino101Led1 BluetoothDevice  to
⦁ Intensity – The Intensity of the LED valued from 1-100. Intensity will only affect the brightness of the LED if it is plugged into a pin supporting pulse width modulation (PWM). For the Arduino 101, the PWM pins are 3, 5, 6, and 9. For all other pins the LED will either turn on or off with no change in intensity.
get Arduino101Led1 Intensity
set Arduino101Led1 Intensity  to
⦁ On – Get whether the device attached to the Arduino 101 is turned on. This is a best guess approximation given the connected state of the Bluetooth low energy component and previous calls to TurnOn and TurnOff.
get Arduino101Led1 On
⦁ Pin – The Pin on the Arduino board that the device is wired in to.
get Arduino101Led1 Pin
set Arduino101Led1 Pin  to

Methods

⦁ IsSupported – Tests whether the Bluetooth low energy device is broadcasting support for the service. If true, calls to TurnOn and TurnOff should work correctly. Otherwise an error will be reported through the Screen's ErrorOccurred event.

call Arduino101Led1 IsSupported
⦁ TurnOff – Turn off the connected device.
call Arduino101Led1 TurnOff
⦁ TurnOn – Turn on the connected device.
call Arduino101Led1 TurnOn


Arduino101Humidity


The Arduino101Humidity component lets users gather humidity and temperature data from a Grove DHT11 sensor. Temperature data are reported in degrees Celsius and the relative humidity is reported in percent.
Image of a Grove temperature and humidity sensor
More links:
⦁ Download a sample project for the Arduino 101 Humidity sensor.
⦁ Download a sample project for the Arduino 101 Temperature sensor.
⦁ View the how to instructions for the Arduino 101 Humidity sensor.
⦁ View the how to instructions for the Arduino 101 Temperature sensor.

Properties

⦁ BluetoothDevice – The BluetoothLE component with a connection to the Arduino 101.

get Arduino101Humidity1 BluetoothDevice
set Arduino101Humidity1 BluetoothDevice  to
⦁ Pin – The Pin on the Arduino board that the device is wired in to.
get Arduino101Humidity1 Pin
set Arduino101Humidity1 Pin  to

Methods

⦁ IsSupported – Tests whether the Bluetooth low energy device is broadcasting support for the service. If true, calls to TurnOn and TurnOff should work correctly. Otherwise an error will be reported through the Screen's ErrorOccurred event.

call Arduino101Humidity1 IsSupported
⦁ ReadHumidity – Read the current humidity from the attached sensor. On success, the HumidityReceivedevent will be run with the received humidity measurement.
call Arduino101Humidity1 ReadHumidity
⦁ ReadTemperature – Read the current temperature from the attached sensor. On success, the TemperatureReceived event will be run with the received temperature measurement.
call Arduino101Humidity1 ReadTemperature
⦁ RequestHumidityUpdates – Request notifications from the Arduino for changes in the humidity sensor reading. The HumidityReceived event will be run as samples are received from the Arduino.
call Arduino101Humidity1 RequestHumidityUpdates
⦁ RequestTemperatureUpdates – Request notifications from the Arduino for changes in the temperature sensor reading. The TemperatureReceived event will be run as samples are received from the Arduino.
call Arduino101Humidity1 RequestTemperatureUpdates
⦁ StopHumidityUpdates – Stop listening for notifications of changes in the humidity sensor reading. This only has an effect if there was a previous call to RequestHumidityUpdates. There may be additional pending messages that will be processed by running HumidityReceived.
call Arduino101Humidity1 StopHumidityUpdates
⦁ StopTemperatureUpdates – Stop listening for notifications of changes in the temperature sensor reading. This only has an effect if there was a previous call to RequestTemperatureUpdates. There may be additional pending messages that will be processed by running TemperatureReceived.
call Arduino101Humidity1 StopTemperatureUpdates

Events

⦁ HumidityReceived – The HumidityReceived event is run whenever humidity samples are received from the Arduino. This is usually a result of performing a read or request operation. The humidity value is a relative humidity between 0-100%.

   Parameters:
   ⚬ humidity (number) — The relative humidity, in percent.

when Arduino101Humidity1 HumidityReceived humidity do
⦁ TemperatureReceived – The TemperatureReceived event is run whenever temperature samples are received from the Arduino. This is usually a result of performing a <a href="#ReadTemperature>read or requestoperation. The temperature value is measured in degrees Celsius.
   Parameters:
   ⚬ temperature (number) — The temperature, in degrees Celsius.
when Arduino101Humidity1 TemperatureReceived temperature do