Kinetic Sculpture  3.1
Software to Architecture for the Junior Kinetic Sculpture Project
 All Classes Files Functions Variables Macros Pages
Globals.h
Go to the documentation of this file.
1 
3 #include "Motor.h"
4 #include "Ultrasonic.h"
5 #include "Switch.h"
6 #include "LEDStrip.h"
7 #include "Disc.h"
8 
9 #define RED 255, 0, 0
10 #define GREEN 0, 255, 0
11 #define BLUE 0, 0, 255
12 #define YELLOW 255, 255, 0
13 #define ORANGE 255, 140, 0
14 #define MAGENTA 255, 0, 255
15 #define BLACK 0, 0, 0
16 #define WHITE_FULL 255, 255, 255
17 #define WHITE 255, 255, 135
18 #define WHITE_MEDIUM 128, 128, 67
19 #define WHITE_LOW 64, 64, 34
20 #define WHITE_VERY_LOW 48, 48, 25
21 #define WHITE_VERY_VERY_LOW 32, 32, 17
23 void setupGlobals();
24 void frontDiscISR();
25 void backDiscISR();
26 
30 const int BIT_1_SWITCH_PIN = 63;
33 const int BIT_2_SWITCH_PIN = 64;
36 const int BIT_3_SWITCH_PIN = 65;
43 const int RIGHT_MOTOR_DIRECTION_PIN = 14;
44 const int RIGHT_MOTOR_PWM_PIN = 12;
45 const int RIGHT_MOTOR_TACHOMETER = 18;
49 const int LEFT_MOTOR_DIRECTION_PIN = 15;
50 const int LEFT_MOTOR_PWM_PIN = 11;
51 const int LEFT_MOTOR_TACHOMETER = 19;
59 Disc backDisc(&rightMotor);
60 Disc frontDisc(&leftMotor);
65 const int BACKLIGHT_RED_PIN = 6;
66 const int BACKLIGHT_GREEN_PIN = 8;
67 const int BACKLIGHT_BLUE_PIN = 7;
68 const int LED_PIN = 13;
75 const int US_TRIGGER = 4;
76 const int US_ECHO = 3;
78  US_ECHO);
86 void setupGlobals() {
87  Serial.begin(9600);
88  pinMode(LED_PIN, OUTPUT);
89 
90  attachInterrupt(digitalPinToInterrupt(frontDisc.motor->getTachAttachedPin()), frontDiscISR, RISING);
91  attachInterrupt(digitalPinToInterrupt(backDisc.motor->getTachAttachedPin()), backDiscISR, RISING);
92 }
93 
97 void frontDiscISR() {
98  frontDisc.motor->interruptServiceRoutine();
99 }
100 
104 void backDiscISR() {
105  backDisc.motor->interruptServiceRoutine();
106 }
107 
111 void easterEgg(){
112  for(int i = 0; i <= 2; i++){
113  ledBacklights.setColor(random(0, 255), random(0, 255), random(0, 255));
114  delay(150);
115  ledBacklights.setColor(0,0,0);
116  delay(100);
117  }
118 
119  delay(100);
120 
121  for(int i = 0; i <=2; i ++){
122  ledBacklights.setColor(random(0, 255), random(0, 255), random(0, 255));
123  delay(250);
124  ledBacklights.setColor(0,0,0);
125  delay(100);
126  }
127 
128  delay(100);
129 
130  for(int i = 0; i <= 2; i++){
131  ledBacklights.setColor(random(0, 255), random(0, 255), random(0, 255));
132  delay(150);
133  ledBacklights.setColor(0,0,0);
134  delay(100);
135  }
136 }
const int LEFT_MOTOR_PWM_PIN
Definition: Globals.h:50
LEDStrip ledBacklights(BACKLIGHT_RED_PIN, BACKLIGHT_GREEN_PIN, BACKLIGHT_BLUE_PIN)
Disc frontDisc & leftMotor
Definition: Globals.h:60
const int LEFT_MOTOR_DIRECTION_PIN
Definition: Globals.h:49
void frontDiscISR()
Definition: Globals.h:97
void setupGlobals()
Definition: Globals.h:86
const int LED_PIN
Definition: Globals.h:68
Definition: Motor.h:11
const int RIGHT_MOTOR_PWM_PIN
Definition: Globals.h:44
void easterEgg()
Definition: Globals.h:111
const int BACKLIGHT_RED_PIN
Definition: Globals.h:65
const int LEFT_MOTOR_TACHOMETER
Definition: Globals.h:51
Definition: Switch.h:11
const int BACKLIGHT_BLUE_PIN
Definition: Globals.h:67
const int BIT_3_SWITCH_PIN
Definition: Globals.h:36
const int RIGHT_MOTOR_DIRECTION_PIN
Definition: Globals.h:43
Switch bit3Switch(BIT_3_SWITCH_PIN)
const int US_ECHO
Definition: Globals.h:76
const int RIGHT_MOTOR_TACHOMETER
Definition: Globals.h:45
Definition: Ultrasonic.h:10
Disc backDisc & rightMotor
Definition: Globals.h:59
const int BACKLIGHT_GREEN_PIN
Definition: Globals.h:66
Definition: Disc.h:14
Switch bit2Switch(BIT_2_SWITCH_PIN)
void setColor(byte red, byte green, byte blue)
Definition: LEDStrip.h:104
Definition: LEDStrip.h:30
void backDiscISR()
Definition: Globals.h:104
const int US_TRIGGER
Definition: Globals.h:75
Ultrasonic ultrasonicSensor(US_TRIGGER, US_ECHO)
const int BIT_2_SWITCH_PIN
Definition: Globals.h:33
Switch bit1Switch(BIT_1_SWITCH_PIN)
const int BIT_1_SWITCH_PIN
Definition: Globals.h:30