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
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
ANALOG1
ANALOG2
ANALOG3
ANALOG4
ANALOG5
ANALOG6
ANALOG7
{
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
value is the analog value (0-255).
{
analogWrite(DIGITAL1, 127);
}
analogRead(analog input)
Digital pin
=>
14
=>
15
=>
16
=>
17
=>
18
=>
19
=>
20
is used, the function's input parameter will be the name of
analogWrite(DIGITAL1, value);
-44-
Hardware
where
v6.3
Need help?
Do you have a question about the Waspmote and is the answer not in the manual?