0% found this document useful (0 votes)
5K views3 pages

Nuw Sourcecode

Arduino sourcecode for making a clock that displays the time in RGB resistor codes.

Uploaded by

lvolders4833
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5K views3 pages

Nuw Sourcecode

Arduino sourcecode for making a clock that displays the time in RGB resistor codes.

Uploaded by

lvolders4833
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

// Attiny85 code for making a resistor code clock

#include <Time.h>
#include <Adafruit_NeoPixel.h>
// Which pin on the Attiny85 is connected to the NeoPixels?
#define PIN
1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS
4
// When we setup the NeoPixel library, we tell it how many pixels, and which pin
to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parame
ter
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ80
0);
int
int
int
int
int
int
int

toets1=0;
toets2=2;
wait;
tel;
tel1=0;
tel2=0;
i=0;

const int clockcolor[10][3] ={


// dit array bevat de weerstands codes voor de getallen 0 tot 9
// this array contains the resistor colour codes
{000,000,000}, // 0 black
{21,0,0}, // 1 brown
{255,0,0}, // 2 red
{255,37,3}, // 3 orange
{255,255,0}, // 4 yellow
{0,255,0}, // 5 green
{0,0,255}, // 6 blue
{14,1,42}, // 7 purple
{37,37,37}, // 8 grey
{255,255,255} // 9 white
};
void setup()
{
pinMode(0,INPUT_PULLUP);
pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
setTime(00, 59, 00, 1, 1, 2016);
pixels.begin(); // This initializes the NeoPixel library.
int wait = second();
for(int i=0;i<NUMPIXELS;i++)
{
int wait = second();
pixels.setPixelColor(i, 0,0,255);
pixels.show();
while ((second()-wait)<1)
{}
}
}

void loop()
{
keyhourl();
// check keypressed
// this is for setting the time
setresval();
}
void setresval()
{
// first led is hours 0 1 or 2
int hourh=hour();
int hourhigh = 0;
int i;
for (i=3; i>0; i--)
{
hourh = hour()- (i*10);
if ((hourh<10) && (hourh >-1))
{
hourhigh =i;
}
pixels.setPixelColor(3,clockcolor[hourhigh][0],clockcolor[hourhigh][1],clockc
olor[hourhigh][2]);
pixels.show();
}
// }// second led is hours 0 to 9
int hourl;
hourl = hour()-(10*hourhigh);
pixels.setPixelColor(2,clockcolor[hourl][0],clockcolor[hourl][1],clockcolor[ho
url][2]);
pixels.show();
// third led is miniutes 0,1,2,3,4 or 5
int minh=minute();
int minhigh = 0;
for (i=5; i>0; i--)
{
minh = minute()- (i*10);
if ((minh<10) && (minh >-1))
{
minhigh =i;
}
pixels.setPixelColor(1,clockcolor[minhigh][0],clockcolor[minhigh][1],clockcol
or[minhigh][2]);
pixels.show();
}
// fourth led is minutes 0 to 9
int minl;
minl = minute()-(10*minhigh);
pixels.setPixelColor(0,clockcolor[minl][0],clockcolor[minl][1],clockcolor[minl
][2]);
pixels.show();
}
void keyhourl()
{

if (digitalRead(toets1)==LOW)
{
tel1=hour()+1;
setTime(hour()+1,minute(),second(),1,1,2015);
delay(200);
}
if (digitalRead(toets2)==LOW)
{
tel2=minute()+1;
setTime(hour(),tel2,second(),1,1,2015);
delay(200);
}
}

You might also like