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 | int red=3; int green=5; int blue=6; void setup() { pinMode(red,OUTPUT); pinMode(green,OUTPUT); pinMode(blue,OUTPUT); } void loop() { redlight(); delay(1000); greenlight(); delay(1000); bluelight(); delay(1000); colormix(200,20,10); delay(2000); } void redlight() { digitalWrite(red,LOW); digitalWrite(green,HIGH); digitalWrite(blue,HIGH); } void greenlight() { digitalWrite(red,HIGH); digitalWrite(green,LOW); digitalWrite(blue,HIGH); } void bluelight() { digitalWrite(red,HIGH); digitalWrite(green,HIGH); digitalWrite(blue,LOW); } void colormix(int R,int G,int B) { analogWrite(red,R); analogWrite(green,G); analogWrite(blue,B); } |
欢迎光临 创客联盟网 (https://immaker.org/) | Powered by Discuz! X3.3 |