-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew planetry
154 lines (143 loc) · 3.9 KB
/
new planetry
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
Installation:
Arduino Uno P10 Panel
13 ---------> S / CLK
11 ---------> R
9 ---------> nOE / OE
8 ---------> L / SCLK
7 ---------> B
6 ---------> A
GND ---------> GND
-----------------------------------------------------------------------------------------------------------------------------------------
Load cell installation
2 -> HX711 CLK
3 -> DOUT
5V -> VCC
GND -> GND
*/
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include <SoftwareSerial.h>
#include "Arial_black_16.h"
#include "Arial_Black_16_ISO_8859_1.h"
#include "Arial14.h"
#include "SystemFont5x7.h"
#include "HX711.h"
#include <HX711_ADC.h>
#define FONT Arial_Black_16
#define DISPLAYS_ACROSS 1 //-> Number of P10 panels used, side to side.
#define DISPLAYS_DOWN 1
#define calibration_factor -12.20
#define LOADCELL_DOUT_PIN 3
#define LOADCELL_SCK_PIN 2
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
HX711 scale(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
char *Text = "";
char chr[5];
int knob = 0;
double load, fload;
int value = A0;
// 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 potentiometer(4, 5);
void ScanDMD()
{
dmd.scanDisplayBySPI();
}
void setup(void)
{
Timer1.initialize(5000);
Timer1.attachInterrupt(ScanDMD);
dmd.clearScreen(true);
Serial.begin(9600);
scale.set_scale(calibration_factor);
scale.tare();
// scale.setReverseOutput();
}
void drawText( String dispString )
{
dmd.clearScreen( true );
dmd.selectFont( SystemFont5x7 );
char newString[256];
int sLength = dispString.length();
dispString.toCharArray( newString, sLength + 1 );
dmd.drawMarquee( newString , sLength , ( 32 * DISPLAYS_ACROSS ) - 1 , 0);
long start = millis();
long timer = start;
long timer2 = start;
boolean ret = false;
while ( !ret ) {
if ( ( timer + 150 ) < millis() ) {
ret = dmd.stepMarquee( -1 , 0 );
timer = millis();
}
}
}
void loop(void)
{
while (true)
{
load = scale.get_units(), 10;
knob = analogRead(value);
Serial.print(knob);
if (knob == 0)
{
dmd.selectFont(SystemFont5x7);
drawText("Move: ");
fload = (-1) * (load * 27.01);
// Text = str(fload);
dmd.drawMarquee(Text, strlen(Text), (32 * DISPLAYS_ACROSS) - 1, 0);
}
if ((knob > 0) && (knob <= 100))
{
fload = (-1) * (load * 27.01);
Serial.println(fload);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "SUN: ", 8, GRAPHICS_NORMAL);
dtostrf(fload, 3, 2, chr);
dmd.drawString( 0, 9, chr, 8, GRAPHICS_NORMAL );
//delay(5000);
}
if ((knob > 100) && (knob <= 200))
{
fload = (-1) * (load * 0.38);
Serial.println(fload);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "MERCURY:", 8, GRAPHICS_NORMAL);
dtostrf(fload, 3, 2, chr);
dmd.drawString( 0, 9, chr, 8, GRAPHICS_NORMAL );
//delay(5000);
}
if ((knob > 200) && (knob <= 300))
{
fload = (-1) * (load * 0.166);
Serial.println(fload);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "MOON: ", 8, GRAPHICS_NORMAL);
dtostrf(fload, 3, 2, chr);
dmd.drawString( 0, 9, chr, 8, GRAPHICS_NORMAL );
//delay(5000);
}
if ((knob > 300) && (knob <= 400))
{
fload = (-1) * (load * 2.34);
Serial.println(fload);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "JUPITER:", 8, GRAPHICS_NORMAL);
dtostrf(fload, 3, 2, chr);
dmd.drawString( 0, 9, chr, 8, GRAPHICS_NORMAL );
//delay(5000);
}
if ((knob > 400) && (knob <= 500))
{
fload = (-1) * (load * 1.19);
Serial.println(fload);
dmd.selectFont(SystemFont5x7);
dmd.drawString(0, 0, "NEPTUNE:", 8, GRAPHICS_NORMAL);
dtostrf(fload, 3, 2, chr);
dmd.drawString( 0, 9, chr, 8, GRAPHICS_NORMAL );
//delay(5000);
}
}
}