Quellcode |
|
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
int const Red = 3; //pin 3 int const Blue = 6; // pin 6 int const Green = 5; // pin 5 int const PinYellow = 14; //InPin int const PinGreen = 15; //InPin int const PinWhite = 17; //InPin int const PinBlue = 16; //InPin int const PinBlack = 18; //InPin int prevR = 0; int prevG = 0; int prevB = 0; int InYellow = 0; void setup(){ Serial.begin(9600); pinMode(Red, OUTPUT); pinMode(Blue, OUTPUT); pinMode(Green, OUTPUT); pinMode(PinYellow, INPUT); pinMode(PinGreen, INPUT); pinMode(PinBlue, INPUT); pinMode(PinWhite, INPUT); pinMode(PinBlack, INPUT); } void loop() { //main loop of the program //InYellow = digitalRead(PinYellow); if (digitalRead(PinYellow) == LOW) { YellowBlink(); } if (digitalRead(PinYellow)== HIGH){ AusF(); } if (digitalRead(PinGreen) == LOW) { GreenBlink(); } if (digitalRead(PinGreen)== HIGH){ AusF(); } if (digitalRead(PinBlue) == LOW) { BlueBlink(); } if (digitalRead(PinBlue)== HIGH){ AusF(); } if (digitalRead(PinWhite) == LOW) { WhiteBlink(); } if (digitalRead(PinWhite)== HIGH){ AusF(); } if (digitalRead(PinBlack) == LOW) { BlackBlink(); } if (digitalRead(PinBlack)== HIGH){ AusF(); } } ///////// ///////// Blinkfunktion ////////// void YellowBlink(){ for (int x = 0; x < 20000; x++){ YellowF(); } for (int y = 0; y < 10000; y++){ AusF(); } } void BlueBlink(){ for (int x = 0; x < 30000; x++){ BlueF(); } for (int y = 0; y < 10000; y++){ AusF(); } } void WhiteBlink(){ for (int x = 0; x < 30000; x++){ WhiteF(); } for (int y = 0; y < 10000; y++){ AusF(); } } void GreenBlink(){ for (int x = 0; x < 30000; x++){ GreenF(); } for (int y = 0; y < 10000; y++){ AusF(); } } void BlackBlink(){ for (int x = 0; x < 20000; x++){ BlackF(); } for (int y = 0; y < 10000; y++){ AusF(); } } /////////// ////////// Ausschalter ////////// void AusF(){ int prevR = 0; int prevG = 0; int prevB = 0; analogWrite(Red, prevR ); analogWrite(Green, prevG); analogWrite(Blue, prevB); } //////////// //////////// Farben deklariert /////////// void YellowF (){ int prevR = 255; int prevG = 130; int prevB = 1; analogWrite(Red, prevR ); analogWrite(Green, prevG); analogWrite(Blue, prevB); } void BlueF (){ int prevB = 255; analogWrite(Blue, prevB); } void WhiteF (){ int prevR = 255; int prevG = 130; int prevB = 130; analogWrite(Red, prevR ); analogWrite(Green, prevG); analogWrite(Blue, prevB); } void GreenF (){ int prevG= 255; analogWrite(Green, prevG); } void BlackF (){ int prevR = 155; int prevG = 0; int prevB = 255; analogWrite(Red, prevR ); analogWrite(Green, prevG); analogWrite(Blue, prevB); } } |
Dieser Beitrag wurde bereits 17 mal editiert, zuletzt von »Manuel W« (11. Mai 2014, 10:17)
Forensoftware: Burning Board® 3.1.8, entwickelt von WoltLab® GmbH