/*StingRay N.R.M.S by Bree Peng*/
#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
const unsigned char PROGMEM Startup [] = {
0x00, 0x00, 0x10, 0x3C, 0x3E, 0x3F, 0x33, 0x33, 0x33, 0x33, 0xF3, 0xF3, 0xF3, 0x03, 0x03, 0x81,
0xF0, 0xFE, 0x7F, 0x6F, 0x63, 0x63, 0x63, 0xE3, 0xE3, 0xF3, 0x3F, 0x3F, 0x0E, 0x00, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF,
0xE0, 0xF0, 0x7C, 0xFE, 0xFF, 0xFF, 0xFF, 0xC0, 0xF0, 0xF8, 0x3E, 0x1F, 0x07, 0x81, 0xF0, 0xFE,
0x7F, 0x3F, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x03, 0x80, 0xF0, 0xFE, 0x7F, 0x6F, 0x63,
0x63, 0x63, 0xE3, 0xE3, 0xF3, 0x3F, 0x3F, 0x0E, 0x80, 0xF0, 0xFE, 0x7F, 0x3F, 0x31, 0x30, 0x30,
0xF0, 0xFC, 0xFE, 0x0F, 0x07, 0x01, 0x10, 0x3C, 0x3E, 0x3F, 0x33, 0x33, 0x33, 0x33, 0xF3, 0xF3,
0xF3, 0x03, 0x03, 0x01, 0x04, 0x06, 0x06, 0xC6, 0xE6, 0x26, 0x26, 0x26, 0x26, 0x26, 0x07, 0x03,
0x21, 0x20, 0xE2, 0xE3, 0x23, 0x23, 0x20, 0x00, 0xE0, 0xE0, 0x00, 0x03, 0xE3, 0xE3, 0xE0, 0x80,
0x00, 0xE0, 0xE0, 0x00, 0x00, 0xC0, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0xE0, 0xE0,
0x23, 0x23, 0x23, 0xE3, 0xE3, 0x01, 0x00, 0x83, 0xC3, 0xE3, 0xE3, 0xE3, 0xE1, 0x00, 0x00, 0x00,
0xC4, 0xE7, 0xE7, 0x07, 0x86, 0xE6, 0xE6, 0x26, 0x06, 0x06, 0x06, 0x00, 0x00, 0x02, 0x03, 0x03,
0x03, 0x00, 0xE0, 0xE0, 0xE0, 0x80, 0x03, 0xE3, 0xE3, 0x00, 0x00, 0xE2, 0xE3, 0x23, 0x23, 0x20,
0xE0, 0xE0, 0x00, 0x00, 0xE3, 0xE3, 0xE3, 0xE0, 0x04, 0x86, 0xE6, 0xE6, 0xE6, 0xE6, 0x06, 0x06,
0xC6, 0xE6, 0x27, 0x23, 0x21, 0x20, 0x20, 0x00, 0x00, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0D, 0x0F,
0x03, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x07, 0x00, 0x08, 0x0F,
0x07, 0x01, 0x07, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x09, 0x09, 0x0F, 0x07, 0x00,
0x08, 0x0F, 0x07, 0xF1, 0x01, 0x0F, 0x0F, 0xF1, 0x00, 0x0C, 0x0E, 0xF7, 0x03, 0x02, 0x0F, 0xFF,
0x0F, 0x00,
};
const unsigned char PROGMEM Sys [] = {
0x27, 0x25, 0x25, 0x25, 0x25, 0x19, 0x00, 0x00, 0x03, 0x04, 0x3C, 0x04, 0x03, 0x00, 0x27, 0x25,
0x25, 0x25, 0x25, 0x19, 0x00, 0x00, 0x01, 0x01, 0x3F, 0x01, 0x01, 0x00, 0x3F, 0x25, 0x25, 0x25,
0x25, 0x3F, 0x01, 0x1F, 0x38, 0x38, 0x1F, 0x01, 0x3F, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
const unsigned char PROGMEM SysInit [] = {
0x27, 0x25, 0x25, 0x25, 0x25, 0x19, 0x00, 0x00, 0x03, 0x04, 0x3C, 0x04, 0x03, 0x00, 0x27, 0x25,
0x25, 0x25, 0x25, 0x19, 0x00, 0x00, 0x01, 0x01, 0x3F, 0x01, 0x01, 0x00, 0x3F, 0x25, 0x25, 0x25,
0x25, 0x3F, 0x01, 0x1F, 0x38, 0x38, 0x1F, 0x01, 0x3F, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x3F, 0x00, 0x3F, 0x02, 0x04, 0x08, 0x10, 0x3F, 0x00,
0x00, 0x3F, 0x00, 0x00, 0x01, 0x01, 0x3F, 0x01, 0x01, 0x00, 0x3F, 0x00, 0x20, 0x3C, 0x0F, 0x09,
0x0F, 0x38,
};
const unsigned char PROGMEM Count [] = {
0x00, 0x40, 0x78, 0x3F, 0x0F, 0x09, 0x79, 0x79, 0x0F, 0x07, 0x40, 0x78, 0x7E, 0x47, 0x41, 0x61,
0x79, 0x1F, 0x07, 0x00, 0x78, 0x7F, 0x47, 0x40, 0x60, 0x78, 0x1F, 0x07, 0x40, 0x78, 0x3F, 0x0F,
0x3F, 0x7C, 0x78, 0x3F, 0x07, 0x40, 0x78, 0x7F, 0x47, 0x41, 0x61, 0x79, 0x1F, 0x07, 0x40, 0x40,
0x4E, 0x4F, 0x49, 0x69, 0x79, 0x19, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x78, 0x3F, 0x0F,
0x09, 0x09, 0x09, 0x09, 0x01, 0x40, 0x78, 0x3F, 0x07, 0x40, 0x78, 0x3F, 0x0F, 0x09, 0x79, 0x79,
0x0F, 0x07, 0x40, 0x78, 0x7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, 0x1F, 0x1F, 0x1F,
};
const unsigned char PROGMEM One [] = {
0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0xFE, 0xFC, 0xFC, 0xFC, 0xF8,
0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3F, 0x3F,
0x3F, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char PROGMEM Two [] = {
0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7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, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE,
0xFE, 0xFE, 0xFE, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F,
0xFF, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC,
0xFC, 0xFC, 0xFC, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3F,
};
const unsigned char PROGMEM Five [] = {
0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E,
0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 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xFC, 0xFC, 0xFC, 0xF8,
0xF0, 0xE0, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3F,
};
const unsigned char PROGMEM Eight [] = {
0x00, 0x00, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFC, 0xFE, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E,
0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0xFE, 0xFC, 0xFC, 0xFC, 0xF8,
0xF0, 0xE0, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x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xFE, 0x00, 0x5F
};
const unsigned char PROGMEM Blank [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please use SSD1306 128x64!");
#endif
#include <Servo.h>
Servo fire; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 137; // variable to store the servo position
int acc; //acceleration trigger signal
int trig; //fire trigger signal
int opts; //dart sensor signal
int front=255; //front motor duty cycle
int rear=191; //rear motor duty cycle
int rounds=0; //round counter 0's 10's 100's
int roundstens=0;
int roundshundreds=0;
int roundstotal=0;//total rounds
int semi=0; //triggerpull limiter
//For semiautomatic3-round burst, leave the above line alone, for auto, comment it out.
int flash; //flash animation counter
void setup()
{
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C address 0x3C (ebay OLED)
display.drawBitmap(6, 15, Startup, 116, 20, WHITE);
fire.attach(9); // attaches the servo on pin 9 to the servo object
fire.write(pos);
delay(2000); //delay to watch initiating
pinMode(8, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(4, INPUT);
for(flash=0; flash <= 4; flash += 1){
display.drawBitmap(10, 52, Sys, 110, 6, WHITE);
display.drawBitmap(10, 52, SysInit, 110, 6, WHITE);
delay(1);
}
delay(250);
display.clearDisplay();
display.drawBitmap(8, 4, Count, 107, 7, WHITE);
display.drawBitmap(6, 13, Zero, 36, 39, WHITE);
display.drawBitmap(46, 13, Zero, 36, 39, WHITE);
display.drawBitmap(86, 13, Zero, 36, 39, WHITE);
}
void loop(){
opts=digitalRead(4);
acc=digitalRead(7);
trig=digitalRead(8);
if(acc == LOW){
analogWrite(5, front);
analogWrite(6, rear);
if(trig == LOW){
if(semi == 0){ //for automatic comment this line
//if(semi <=2){ //For semiautomatic 3-round burst uncomment this line
if(opts == LOW){ //if a dart is present
fire.write(47); // tell servo to fully extend
roundstotal = roundstotal+1;
rounds = rounds + 1; //counting algorithm for displaying
if(rounds >= 10){
roundstens = roundstens + 1;
rounds = rounds - 10;
}
if(roundstens >= 10){
roundshundreds = roundshundreds + 1;
roundstens = roundstens - 10;
}
if(roundshundreds >= 10){
rounds = 0;
roundstens = 0;
roundshundreds = 0;
}
//break for one's units place
if(rounds == 0){
display.drawBitmap(86, 13, Zero, 36, 39, WHITE);
}else if(rounds == 1){
display.drawBitmap(86, 13, One, 36, 39, WHITE);
}else if(rounds == 2){
display.drawBitmap(86, 13, Two, 36, 39, WHITE);
}else if(rounds == 3){
display.drawBitmap(86, 13, Three, 36, 39, WHITE);
}else if(rounds == 4){
display.drawBitmap(86, 13, Four, 36, 39, WHITE);
}else if(rounds == 5){
display.drawBitmap(86, 13, Five, 36, 39, WHITE);
}else if(rounds == 6){
display.drawBitmap(86, 13, Six, 36, 39, WHITE);
}else if(rounds == 7){
display.drawBitmap(86, 13, Seven, 36, 39, WHITE);
}else if(rounds == 8){
display.drawBitmap(86, 13, Eight, 36, 39, WHITE);
}else{
display.drawBitmap(86, 13, Nine, 36, 39, WHITE);
}
//break for tens units place
if(roundstens == 0){
display.drawBitmap(46, 13, Zero, 36, 39, WHITE);
}else if(roundstens == 1){
display.drawBitmap(46, 13, One, 36, 39, WHITE);
}else if(roundstens == 2){
display.drawBitmap(46, 13, Two, 36, 39, WHITE);
}else if(roundstens == 3){
display.drawBitmap(46, 13, Three, 36, 39, WHITE);
}else if(roundstens == 4){
display.drawBitmap(46, 13, Four, 36, 39, WHITE);
}else if(roundstens == 5){
display.drawBitmap(46, 13, Five, 36, 39, WHITE);
}else if(roundstens == 6){
display.drawBitmap(46, 13, Six, 36, 39, WHITE);
}else if(roundstens == 7){
display.drawBitmap(46, 13, Seven, 36, 39, WHITE);
}else if(roundstens == 8){
display.drawBitmap(46, 13, Eight, 36, 39, WHITE);
}else{
display.drawBitmap(46, 13, Nine, 36, 39, WHITE);
}
//break for hundreds place
if(roundshundreds == 0){
display.drawBitmap(6, 13, Zero, 36, 39, WHITE);
}else if(roundshundreds == 1){
display.drawBitmap(6, 13, One, 36, 39, WHITE);
}else if(roundshundreds == 2){
display.drawBitmap(6, 13, Two, 36, 39, WHITE);
}else if(roundshundreds == 3){
display.drawBitmap(6, 13, Three, 36, 39, WHITE);
}else if(roundshundreds == 4){
display.drawBitmap(6, 13, Four, 36, 39, WHITE);
}else if(roundshundreds == 5){
display.drawBitmap(6, 13, Five, 36, 39, WHITE);
}else if(roundshundreds == 6){
display.drawBitmap(6, 13, Six, 36, 39, WHITE);
}else if(roundshundreds == 7){
display.drawBitmap(6, 13, Seven, 36, 39, WHITE);
}else if(roundshundreds == 8){
display.drawBitmap(6, 13, Eight, 36, 39, WHITE);
}else{
display.drawBitmap(6, 13, Nine, 36, 39, WHITE);
}
semi = semi+1;
delay(30); // waits 20ms for the servo to reach the position
fire.write(137); // tell servo to retract
delay(30); // waits 20ms for the servo to reach the position
if(roundstotal > 0){
if(roundstotal%12 == 0){
for(flash=0; flash <= 30; flash += 1){
display.drawBitmap(79, 55, ChangeMag, 48, 8, WHITE);
display.drawBitmap(79, 55, Blank, 48, 8, WHITE);
delay(5);
}
}
}
}
}
else{
delay(5); //delay 5ms
}
}
else if(trig == HIGH){
semi = 0;
}
else{
delay(5); //delay 5ms
}
}
else{
digitalWrite(5,LOW);
digitalWrite(6,LOW);
}
}