Created
November 28, 2020 16:53
-
-
Save vlazar-/2b411e79dc42fde3b35c1a362a8e93f1 to your computer and use it in GitHub Desktop.
Operacija robota
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <MD_Parola.h> | |
#include <MD_MAX72xx.h> | |
#include <SPI.h> | |
#include <WiFi101.h> | |
#include <BlynkSimpleWiFiShield101.h> | |
#define BLYNK_DEBUG | |
char auth[] = ""; //Blynk token | |
char ssid[] = "TICM-Uciona"; //Wifi ssid | |
char pass[] = "TICM-Uciona"; //Wifi lozinka | |
//postavke za MD_Parola biblioteku (rad s 8x8 matricom) | |
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW | |
#define MAX_DEVICES 4 | |
#define CLK_PIN 3 | |
#define DATA_PIN 4 | |
#define CS_PIN 2 | |
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES); | |
uint8_t scrollSpeed = 50; // brzina pomicanja teksta na mled matrici | |
textEffect_t scrollEffect = PA_SCROLL_LEFT; | |
textPosition_t scrollAlign = PA_LEFT; | |
uint16_t scrollPause = 1000; // pauza izmedu pomicanja teksta u milisekundama | |
bool newMessageAvailable = true; | |
SimpleTimer timer; | |
SimpleTimer gameTimer; | |
bool startChanged = false; | |
int buzzerPin = 8; | |
int pincetaPin = 7; | |
int pincetaState = 0; | |
void setup() | |
{ | |
pinMode(buzzerPin, OUTPUT); //high value by default | |
pinMode(pincetaPin, INPUT); //high value by default | |
Serial.begin(9600); | |
Blynk.begin(auth, ssid, pass); | |
P.begin(); | |
// obavijestimo korisnika da je igra upaljena | |
P.displayText("POWER ON! ... Dobrodosli u Robotsku operaciju! Pokrenite igru na mobilnoj aplikaciji!", scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect); | |
timer.setInterval(50, refreshDisplay); | |
} | |
BLYNK_WRITE(V1) | |
{ | |
if (param.asInt() == 1) | |
{ | |
startChanged = true; | |
Serial.println("Restart..."); | |
} | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
timer.run(); | |
if (!digitalRead(pincetaPin) == HIGH) | |
{ | |
tone(buzzerPin, 1000, 500); | |
Serial.println("Greska kirurga"); | |
} | |
} | |
void refreshDisplay() | |
{ | |
//ako je animacija teksta zavrsila, pokreni tekst ponovno | |
if (P.displayAnimate()) | |
{ | |
//tu napraviti promjenu prikaza | |
if (startChanged) | |
{ | |
P.displayText("Operacija u tijeku!", scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect); | |
} | |
P.displayReset(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment