Links

Input/Output pins

Waspmote can communicate with other external devices using different input/output ports.
Figure: I/O sockets in Waspmote
Figure: Description of sensor socket pins
Figure: Description of sensor socket pins

Reading ANALOG inputs

It gets the value read by the corresponding analog input. Waspmote has 7 analog inputs in the sensor connector. Each input is directly connected to the microcontroller. The microcontroller uses a 10-bit 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. To obtain input values, the function analogRead() is used. The value read from this function will be an integer number between 0 and 1023 bits, where 0 corresponds to 0 V and 1023 to 3.3 V.
Example of use:
{
int val1 = analogRead(ANALOG1); // Read the input ANALOG1 and store its value in val1
int val2 = analogRead(ANALOG2); // Read the input ANALOG2 and store its value in val2
int val3 = analogRead(ANALOG3); // Read the input ANALOG3 and store its value in val3
int val4 = analogRead(ANALOG4); // Read the input ANALOG4 and store its value in val4
int val5 = analogRead(ANALOG5); // Read the input ANALOG5 and store its value in val5
int val6 = analogRead(ANALOG6); // Read the input ANALOG6 and store its value in val6
int val7 = analogRead(ANALOG7); // Read the input ANALOG7 and store its value in val7
}

Digital I/O

Setting DIGITAL pin mode

The pinMode() function configures the specified pin as an input or an output.
It returns nothing.
Example of use:
{
pinMode(DIGITAL1, INPUT); // Sets DIGITAL1 as an input
pinMode(DIGITAL4,OUTPUT); // Sets DIGITAL4 as an output
}

Reading DIGITAL Inputs

The digitalRead() function reads the value from the specified digital pin.
It returns '0' or '1'.
Example of use:
{
int val=0;
pinMode(DIGITAL1, INPUT); // Sets DIGITAL1 as an input
val=digitalRead(DIGITAL1); // Reads the value from Digital 1
}

Writing DIGITAL Outputs

The digitalWrite() function writes a HIGH or LOW value to a digital pin. The pin voltage will be set to 3.3 V for a 'HIGH' value, and 0 V for a 'LOW' value.
Example of use:
{
pinMode(DIGITAL4, OUTPUT); // Sets DIGITAL4 as an output
digitalWrite(DIGITAL4, HIGH); // Writes 'High' to Digital 4
}

DIGITAL1 pin as PWM output

There is one pin that can be used as an analog or digital pin.
This pin is called DIGITAL1.
It returns nothing.
Example of use:
{
analogWrite(DIGITAL1, 128); // Writes a value comprised between [0-255] in DIGITAL1
}