-44-
v6.3
Hardware
3.5.1. Analog
Waspmote has
7
accessible analog inputs in the sensor connector. Each input is directly connected to the microcontroller. The
microcontroller uses a
10 bit
successive approximation analog to digital converter (
ADC
). The reference voltage value for the
inputs is
0V
(GND). The maximum value of input voltage is
3.3V
which corresponds with the microcontroller’s general power
voltage.
To obtain input values, the function
analogRead(analog input)
is used, the function’s input parameter will be the name of
the input to be read
“
ANALOG1, ANALOG2…
”
(see sensor connector figure). The value obtained from this function will be an
integer number between
0 and 1023
, 0 corresponds to 0 V and 1023 to 3.3 V.
The analog input pins can also be used as digital input/output pins. If these pins are going to be used as digital ones, the
following correspondence list for pin names must be taken into account:
Analog pin
Digital pin
ANALOG1 => 14
ANALOG2 => 15
ANALOG3 => 16
ANALOG4 => 17
ANALOG5 => 18
ANALOG6 => 19
ANALOG7 => 20
{
val = analogRead(ANALOG1);
}
3.5.2. Digital
Waspmote has digital pins which can be configured as
input or output
depending on the needs of the application. The voltage
values corresponding to the different digital values would be:
-
0V
for logic 0
-
3.3V
for logic 1
The instructions for control of digital pins are:
{
// set DIGITAL3 pin as input and read its value
pinMode(DIGITAL3, INPUT);
val = digitalRead(DIGITAL3);
// set DIGITAL3 pin as output and set it LOW
pinMode(DIGITAL3 ,OUTPUT);
digitalWrite(DIGITAL3, LOW);
}
3.5.3. PWM
DIGITAL1 pin can also be used as output
PWM
(
Pulse Width Modulation
) with which an analog signal can be “simulated”. It
is actually a square wave between 0V and 3.3V for which the proportion of time when the signal is high can be changed (its
working cycle) from 0% to 100%, simulating a voltage of 0V (0%) to 3.3V (100%).The resolution is
8 bit
, so up to 255 values
between 0-100% can be configured. The instruction to control the PWM output is
analogWrite(DIGITAL1, value);
where
value is the analog value (0-255).
{
analogWrite(DIGITAL1, 127);
}
Содержание Waspmote
Страница 1: ...Waspmote Technical Guide ...
Страница 11: ... 11 v6 3 Waspmote Kit Connect the battery in Waspmote Connect the sensor board Switch it on ...
Страница 59: ... 59 v6 3 Sensors Vibration Acceleration Free fall ...
Страница 79: ... 79 v6 3 LoRa Figure Channel frequencies in the 868MHz band Figure Channel frequencies in the 900MHz band ...
Страница 98: ... 98 v6 3 RFID NFC ...