Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #include <Timers.h>
- int j =0;
- int d =0; // Koniec projektu 02,01,2017R.
- int r = 0;
- int w = 0;
- int q =0;
- #define PINLED1 8
- #define PINLED2 7
- const int ZP = 11;
- const int KL = 12;
- const int KP = 13;
- int a = 2;
- const int prog1 = A2;
- const int prog2 = A3;
- #define CCC strip.Color(255, 79, 1) // Kolor kierunku << 255 125 12
- #define BBB strip1.Color(255, 79, 1) // Kolor kierunku << 255 125 12
- int KLewy = 0;
- int KPrawy = 0;
- int ZAP = 0;
- Timers <2> przerw;
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, PINLED1, NEO_GRB + NEO_KHZ800);
- Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(6, PINLED2, NEO_GRB + NEO_KHZ800);
- void setup() {
- // put your setup code here, to run once:
- przerw.attach(1, 121, czas);
- przerw.attach(2, 3106, odczyt);
- strip.begin();
- strip1.begin();
- pinMode(KL, INPUT);
- pinMode(KP, INPUT);
- pinMode(ZP, INPUT);
- pinMode(prog1, INPUT_PULLUP);
- pinMode(prog2, INPUT_PULLUP);
- // Random test LED
- long R,G,B;
- for (int n = 0; n < 6; n++){
- R = random(380); G = random(300); B = random(300);
- strip.setPixelColor(n, strip.Color(R, G, B));
- strip1.setPixelColor(n, strip1.Color(R, G, B));
- strip.show();strip1.show();
- }
- delay(2500);
- strip.clear();strip1.clear();
- strip.show();strip1.show();
- }
- void loop() {
- przerw.process();
- }
- void odczyt() {
- if (digitalRead(prog1)==0 && digitalRead(prog2)== 0){
- a=2;}
- else if(digitalRead(prog1)==1 && digitalRead(prog2)== 0){
- a=1; } //flow led + Amber
- else if (digitalRead(prog1)==0 && digitalRead(prog2)== 1){
- a=0;}//flow led
- else if (digitalRead(prog1)==1 && digitalRead(prog2)== 1){
- a=3;}
- }
- void czas() { // flow led
- KLewy = digitalRead(KL);
- KPrawy = digitalRead(KP);
- ZAP = digitalRead(ZP);
- if (a == 0){
- if (KLewy == 1 && KPrawy == 0) {
- Serial.println(j);
- if (j <=6){
- strip.setPixelColor(j, CCC);
- strip.show();
- j = j+1;
- }
- else if (j > 6 ){
- j = 0;
- strip.clear();
- strip.show();
- delay(700);
- }
- }
- /* if (KLewy == 1) {
- strip.clear();
- strip.show();
- j= 0;
- }*/
- if (KPrawy == 1 && KLewy == 0) {
- if (d <=6){
- strip1.setPixelColor(d, BBB);
- strip1.show();
- d = d+1;
- }
- else if (d > 6 ){
- d = 0;
- strip1.clear();
- strip1.show();
- delay(700);
- }
- }
- /* if (KPrawy == 1) {
- strip1.clear();
- strip1.show();
- d= 0;
- }*/
- if (KPrawy == 1 && KLewy == 1) {
- if (r <=6){
- strip1.setPixelColor(r, BBB);
- strip.setPixelColor(r, CCC);
- strip1.show();
- strip.show();
- r = r+1;
- }
- else if (r > 6 ){
- r = 0;
- strip1.clear();
- strip.clear();
- strip.show();
- strip1.show();
- delay(700);
- }
- }
- if (KPrawy == 0 && KLewy == 0) {
- strip1.clear();
- strip1.show();
- strip.clear();
- strip.show();
- r=0;
- d=0;
- j=0;
- }
- }
- else if (a == 1) { // flow led + Amber
- if (KLewy == 1 && KPrawy ==0) {
- if (j <=6){
- strip.setPixelColor(j, CCC);
- strip.show();
- j = j+1;
- }
- else if (j > 6 ){
- j = 0;
- if (ZAP == 1){
- for (int n = 0; n < 6; n++){
- strip.setPixelColor(n, strip.Color(20, 3, 0));
- }}
- else if (ZAP==0) strip.clear();
- strip.show();
- delay(700);
- }
- }
- if (KPrawy == 1 && KLewy == 0) {
- if (w <=6){
- strip1.setPixelColor(w, BBB);
- strip1.show();
- w = w+1;
- }
- else if (w > 6 ){
- w = 0;
- if (ZAP==1){
- for (int v = 0; v < 6; v++){
- strip1.setPixelColor(v, strip1.Color(20, 3, 0));
- }
- strip1.show();}
- else if (ZAP==0) {
- strip1.clear();
- strip1.show();
- }
- delay(700);
- }
- }
- if (KPrawy == 1 && KLewy == 1) {
- if (q <=6){
- strip1.setPixelColor(q, BBB);
- strip1.show();
- strip.setPixelColor(q, CCC);
- strip.show();
- q = q+1;
- }
- else if (q > 6 ){
- q = 0;
- if (ZAP == 1){
- for (int v = 0; v < 6; v++){
- strip1.setPixelColor(v, strip1.Color(20, 3, 0));
- strip1.show();
- strip.setPixelColor(v, strip.Color(20, 3, 0));
- strip.show();
- }}
- else if (ZAP == 0)
- { strip1.clear();
- strip.clear();
- strip1.show();
- strip.show();
- }
- delay(700);
- }}
- if (KPrawy == 0 && KLewy == 0 && ZAP == 1) {
- for (int s = 0; s < 6; s++){
- strip1.setPixelColor(s, strip1.Color(20, 3, 0));
- strip.setPixelColor(s, strip.Color(20, 3, 0));
- }
- strip1.show();
- strip.show();
- w= 0;
- j=0;
- q=0;
- }
- if (KPrawy == 0 && KLewy == 0 && ZAP == 0) {
- strip1.clear();
- strip.clear();
- strip1.show();
- strip.show();
- w= 0;
- j=0;
- q=0;
- }
- }
- else if (a == 2){ // Ori
- if (KLewy == 1 && KPrawy == 0) {
- for (int n= 0; n<= 6; n++ ){
- strip.setPixelColor(n, CCC);
- strip.show();
- }
- Serial.print("Clear");
- delay(700);
- strip.clear();
- strip.show();
- delay(600);
- }
- else if (KLewy == 0 && KPrawy == 1) {
- for (int m= 0; m<= 6; m++ ){
- strip1.setPixelColor(m, BBB);
- strip1.show();
- }
- delay(700);
- strip1.clear();
- strip1.show();
- delay(600);
- }
- else if (KLewy == 1 && KPrawy == 1) {
- for (int n= 0; n<= 6; n++ ){
- strip.setPixelColor(n, CCC);
- strip.show();
- strip1.setPixelColor(n, BBB);
- strip1.show();
- }
- delay(700);
- strip.clear();
- strip.show();
- strip1.clear();
- strip1.show();
- delay(600);
- }
- else if (KLewy == 0 && KPrawy == 0) {
- strip.clear();
- strip.show();
- strip1.clear();
- strip1.show();
- }
- }
- else if (a == 3){ // Ori kierunki + DRL
- if (KLewy == 1 && KPrawy == 0) {
- for (int n= 0; n<= 6; n++ ){
- strip.setPixelColor(n, CCC);
- strip.show();
- }
- Serial.print("Clear");
- delay(700);
- strip.clear();
- strip.show();
- delay(600);
- }
- else if (KLewy == 0 && KPrawy == 1) {
- for (int m= 0; m<= 6; m++ ){
- strip1.setPixelColor(m, BBB);
- strip1.show();
- }
- delay(700);
- strip1.clear();
- strip1.show();
- delay(600);
- }
- else if (KLewy == 1 && KPrawy == 1) {
- for (int n= 0; n<= 6; n++ ){
- strip.setPixelColor(n, CCC);
- strip.show();
- strip1.setPixelColor(n, BBB);
- strip1.show();
- }
- delay(700);
- strip.clear();
- strip.show();
- strip1.clear();
- strip1.show();
- delay(600);
- }
- else if (KLewy == 0 && KPrawy == 0 && ZAP == 1) {
- delay(600);
- for (int s = 0; s < 6; s++){
- strip1.setPixelColor(s, strip1.Color(255, 245, 200));
- strip.setPixelColor(s, strip.Color(255, 245, 200));
- }
- strip1.show();
- strip.show();
- }
- else if (KLewy == 0 && KPrawy == 0 && ZAP == 0) {
- strip.clear();
- strip.show();
- strip1.clear();
- strip1.show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement