This article by Bo Master original, if there is not the place please specify, reprint please indicate the source.
Reference Blog: http://www.cnblogs.com/jikexianfeng/p/6243654.html
Reference website: http://wiki.geek-workshop.com/doku.php?id=arduino:arduino_language_reference
Reference Document: http://wiring.org.co/reference/
Reference page: http://www.cnblogs.com/jikexianfeng/p/6031291.html
1 /*********************************2 code function: Output analog signal, control the color of RGB lamp3 using functions:4 Pinmode (PIN number, mode);5 Analogwrite (PIN number, voltage parameter); Output analog voltage = 5/256* Voltage parameter6 constrain (input parameter, interval lower bound, upper bounds of interval); Interval function7 random (randomly seeded); Generate a random number8 for specific function usage, please refer to another blogger document: "Arduino API Manual"9 Website:http://www.cnblogs.com/jikexianfeng/p/6243654.htmlTen creation time: 2017*1*4 One Author Email: [Email protected] A ********************************/ - intRedpin = One;//Red - intGreenpin =Ten;//Green the intBluepin =9;//Blue - - voidSetup () { - Pinmode (redpin,output); + Pinmode (greenpin,output); - Pinmode (bluepin,output); + } A voidLoop () at { -Randomseed (Analogread (0)); - for(intx=0; x< the; x + +){ - -Analogwrite (Redpin,constrain (Random ( the),0,255)); -Analogwrite (Greenpin,constrain (Random ( the),0,255)); inAnalogwrite (Bluepin,constrain (Random ( the),0,255)); -Delay -); to } +}
Output seven colors with RGB lamp