4.5.1. Analog pins
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 0 V (GND). The maximum value of input voltage is 3.3 V which
corresponds with the microcontroller's general power voltage.
To obtain input values, the function
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
ANALOG1
ANALOG2
ANALOG3
ANALOG4
ANALOG5
ANALOG6
ANALOG7
{
val = analogRead(ANALOG1);
}
4.5.2. Digital pins
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:
0 V for logic 0
•
LOW:
3.3 V for logic 1
•
HIGH:
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);
}
4.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 0 V and 3.3 V 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 0 V (0%) to 3.3 V (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);
{
analogWrite(DIGITAL1, 127);
}
analogRead(analog input)
Digital pin
=>
14
=>
15
=>
16
=>
17
=>
18
=>
19
=>
20
where value is the analog value (0-255).
is used, the function's input parameter will be the
-60-
Hardware
v8.2
Need help?
Do you have a question about the Waspmote and is the answer not in the manual?