-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanetary_weights.ino
127 lines (117 loc) · 3.07 KB
/
planetary_weights.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
// Create an LCD object. Parameters: (RS, E, D4, D5, D6, D7):
LiquidCrystal lcd = LiquidCrystal(2, 3, 4, 5, 6, 7);
double knob, load;
// software serial #1: RX = digital pin 10, TX = digital pin 11
SoftwareSerial portOne(10, 11);
// software serial #2: RX = digital pin 8, TX = digital pin 9
// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
SoftwareSerial portTwo(8, 9);
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
//Specify LCD's columns and rows.
lcd.begin(16,2);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
// Start each software serial port
portOne.begin(9600);
portTwo.begin(9600);
}
void loop()
{
// By default, the last intialized port is listening.
// when you want to listen on a port, explicitly select it:
portOne.listen();
Serial.println("Data from port one:");
// while there is data coming in, read it
// and send to the hardware serial port:
while (portOne.available() > 0)
{
load = portOne.read();
Serial.write(load);
break;
}
// blank line to separate data from the two ports:
Serial.println();
// Now listen on the second port
portTwo.listen();
// while there is data coming in, read it
// and send to the hardware serial port:
Serial.println("Data from port two:");
while (portTwo.available() > 0)
{
knob = portTwo.read();
Serial.write(knob);
break;
}
// blank line to separate data from the two ports:
Serial.println();
// potentiometer inputs
if ((portTwo.available() > 0))
{
switch (knob)
{
case ((knob > 0) && (knob <= 300)):
{
lcd.setCursor(0, 0);
lcd.digitalWrite("Mercury: ");
lcd.setCursor(0, 1);
lcd.digitalWrite(load * 1);
}
case ((knob > 300) && (knob <= 600)):
{
lcd.setCursor(0, 0);
lcd.digitalWrite("Venus: ");
lcd.setCursor(0, 1);
lcd.digitalWrite(load * 1);
}
case ((knob > 600) && (knob <= 900)):
{
lcd.setCursor(0, 0);
lcd.digitalWrite("Mars: ");
lcd.setCursor(0, 1);
lcd.digitalWrite(load * 1);
}
case ((knob > 900) && (knob <= 1200)):
{
lcd.setCursor(0, 0);
lcd.digitalWrite("Jupiter: ");
lcd.setCursor(0, 1);
lcd.digitalWrite(load * 1);
}
case ((knob > 1200) && (knob <= 1500)):
{
lcd.setCursor(0, 0);
lcd.digitalWrite("Saturn: ");
lcd.setCursor(0, 1);
lcd.digitalWrite(load * 1);
}
case ((knob > 1200) && (knob <= 1500)):
{
lcd.setCursor(0, 0);
lcd.digitalWrite("Uranus: ");
lcd.setCursor(0, 1);
lcd.digitalWrite(load * 1);
}
case ((knob > 1200) && (knob <= 1500)):
{
lcd.setCursor(0, 0);
lcd.digitalWrite("Neptune: ");
lcd.setCursor(0, 1);
lcd.digitalWrite(load * 1);
}
case ((knob > 1200) && (knob <= 1500)):
{
lcd.setCursor(0, 0);
lcd.digitalWrite("Pluto: ");
lcd.setCursor(0, 1);
lcd.digitalWrite(load * 1);
}
}
}
}