-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateEvent.java
More file actions
38 lines (28 loc) · 1.11 KB
/
CreateEvent.java
File metadata and controls
38 lines (28 loc) · 1.11 KB
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
import grovepi.GrovePi;
import grovepi.Pin;
import grovepi.sensors.*;
/**
This program creates an event then sends it to the server (placeholder).
**/
class CreateEvent {
public static void main(String[] args) {
GrovePi grovePi = new GrovePi();
//button is used for this demo, in reality they confirm by dropping ball in the Yes section
ButtonSensor confirmBtn = grovePi.getDeviceFactory().createButtonSensor(Pin.DIGITAL_PIN_7);
while(true) {
//user confirms event
if(confirmBtn.isPressed()) {
int selection = SetButtonLED.selection;
int date = grovePi.analogRead(Pin.ANALOG_PIN_0);
int time = grovePi.analogRead(Pin.ANALOG_PIN_1);
sendToServer(selection, date, time);
}
int light = grovePi.analogRead(Pin.ANALOG_PIN_0) / 10;
grovePi.analogWrite(Pin.DIGITAL_PIN_3, 125-light);
}
}
public void sendToServer(int selection, int date, int time) {
//this will convert date and time into actual figures
//then send data to the server
}
}