Editing
RGBpixel
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Simple Test === <pre> /* Developed by: thex (noisebridge) Updated: 20131122 Revised: 20140829 (evil dan) https://noisebridge.net/wiki/RGBpixel */ // Arduino UNO Default wiring, Yellow to Pin 13 & Green to Pin 11 #include <SPI.h> int waitTime = 100; byte maxPower = 0x33; int offset = 0; /* color hex r g b deg ========================================== RED #FF0000 255, 0, 0 0 ORANGE #FF7F00 255, 127, 0 30 YELLOW #FFFF00 255, 255, 0 60 CHARTREUSE #7FFF00 127, 255, 0 90 GREEN #00FF00 0, 255, 0 120 SPRING #00FF7F 0, 255, 127 150 CYAN #00FFFF 0, 255, 255 180 AZURE #007FFF 0, 127, 255 210 BLUE #0000FF 0, 0, 255 240 VIOLET #7F00FF 127, 0, 255 270 MAGENTA #FF00FF 255, 0, 255 300 ROSE #FF007F 255, 0, 127 330 */ void setup() { // Set the SPI parameters SPI.begin(); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE0); SPI.setClockDivider(SPI_CLOCK_DIV2); sendEmptyFrame(); } void loop() { for (int o = 0; o < offset; o++) sendColor(maxPower, maxPower, maxPower); offset++; if (offset > 25) offset = 0; for (int i = 0; i < 2; i++) { // RED sendColor(maxPower,0x00,0x00); // ORANGE sendColor(maxPower, maxPower>>1, 0x00); // YELLOW sendColor(maxPower, maxPower, 0x00); // CHARTREUSE sendColor(maxPower>>1, maxPower, 0x00); // GREEN sendColor(0x00,maxPower,0x00); // SPRING sendColor(0x00, maxPower, maxPower>>1); // CYAN sendColor(0x00, maxPower, maxPower); // AZURE sendColor(0x00, maxPower>>1, maxPower); // BLUE sendColor(0x00,0x00,maxPower); // VIOLOET sendColor(maxPower>>1, 0x00, maxPower); // MAGENTA sendColor(maxPower, 0x00, maxPower); // ROSE sendColor(maxPower, 0x00, maxPower>>1); } sendEmptyFrame(); delay(waitTime); } // Extrapolated functions from TCL Library void sendFrame(byte flag, byte red, byte green, byte blue) { SPI.transfer(flag); SPI.transfer(blue); SPI.transfer(green); SPI.transfer(red); } void sendColor(byte red, byte green, byte blue) { byte flag; flag = makeFlag(red,green,blue); sendFrame(flag,red,green,blue); } void sendEmptyFrame() { sendFrame(0x00, 0x00, 0x00, 0x00); } byte makeFlag(byte red, byte green, byte blue) { byte flag = 0; flag = (red&0xC0)>>6; flag |= ((green&0xC0)>>4); flag |= ((blue&0xC0)>>2); return ~flag; } </pre>
Summary:
Please note that all contributions to Noisebridge are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Noisebridge:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Request account
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Dig in!
Noisebridge
- Status: MOVED
- Donate
- ABOUT
- Accessibility
- Vision
- Blog
Manual
MANUAL
Visitors
Participation
Community Standards
Channels
Operations
Events
EVENTS
Guilds
GUILDS
- Meta
- Electronics
- Fabrication
- Games
- Music
- Library
- Neuro
- Philosophy
- Funding
- Art
- Crypto
- Documentation/Wiki
Wiki
Recent Changes
Random Page
Help
Categories
(Edit)
Tools
What links here
Related changes
Special pages
Page information