UT 09: Analog pins
This example shows how to set up the power supply lines in the Waspmote I/O sockets

Required Materials

1 x Waspmote 1 x MiniUSB wire 1 x Battery

Notes

This example can be executed in Waspmote v12 and Waspmote v15

Code

1
/*
2
* ------ [UT_09] - Analog pins --------
3
*
4
* Explanation: This example shows how to set up the power supply lines
5
* in the Waspmote I/O sockets
6
*
7
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
8
* http://www.libelium.com
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the GNU General Public License
21
* along with this program. If not, see .
22
*
23
* Version: 3.0
24
* Design: David Gascon
25
* Implementation: Yuri Carmona
26
*/
27
28
// define variables
29
int analog1;
30
int analog2;
31
int analog3;
32
int analog4;
33
int analog5;
34
int analog6;
35
int analog7;
36
37
void setup()
38
{
39
USB.ON();
40
USB.println(F("UT_09 example"));
41
USB.println(F("------------------------------------------"));
42
USB.println(F("Analog output (0 - 3.3V): from 0 to 1023"));
43
USB.println(F("------------------------------------------"));
44
}
45
46
47
void loop()
48
{
49
// read analog pins
50
analog1 = analogRead(ANALOG1);
51
analog2 = analogRead(ANALOG2);
52
analog3 = analogRead(ANALOG3);
53
analog4 = analogRead(ANALOG4);
54
analog5 = analogRead(ANALOG5);
55
analog6 = analogRead(ANALOG6);
56
analog7 = analogRead(ANALOG7);
57
58
// show values
59
USB.print(F("ANALOG1: "));
60
USB.println(analog1);
61
USB.print(F("ANALOG2: "));
62
USB.println(analog2);
63
USB.print(F("ANALOG3: "));
64
USB.println(analog3);
65
USB.print(F("ANALOG4: "));
66
USB.println(analog4);
67
USB.print(F("ANALOG5: "));
68
USB.println(analog5);
69
USB.print(F("ANALOG6: "));
70
USB.println(analog6);
71
USB.print(F("ANALOG7: "));
72
USB.println(analog7);
73
74
USB.println(F("------------------------------------------"));
75
delay(1000);
76
}
77
78
Copied!

Output

1
H#
2
UT_09 example
3
------------------------------------------
4
Analog output (0 - 3.3V): from 0 to 1023
5
------------------------------------------
6
ANALOG1: 4
7
ANALOG2: 9
8
ANALOG3: 38
9
ANALOG4: 29
10
ANALOG5: 251
11
ANALOG6: 149
12
ANALOG7: 111
13
------------------------------------------
14
ANALOG1: 58
15
ANALOG2: 45
16
ANALOG3: 56
17
ANALOG4: 42
18
ANALOG5: 219
19
ANALOG6: 150
20
ANALOG7: 110
21
------------------------------------------
22
ANALOG1: 63
23
ANALOG2: 48
24
ANALOG3: 59
25
ANALOG4: 42
26
ANALOG5: 207
27
ANALOG6: 141
28
ANALOG7: 103
29
------------------------------------------
Copied!
Last modified 1yr ago