diff --git a/AAA b/AAA
new file mode 100644
index 0000000..71d8711
--- /dev/null
+++ b/AAA
@@ -0,0 +1,21 @@
+/*
+ Blink
+ Turns on an LED on for one second, then off for one second, repeatedly.
+
+ This example code code code codecodecodecodecodecodecodecodecodecodecodecode is in the public domain.
+ */
+int LEDPIN = 13;
+
+void setup() {
+ //Serial.begin(9600);
+ // initialize the digital pin as an output.
+ // Pin 13 has an LED connected on most Arduino boards:
+ pinMode(LEDPIN, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(LEDPIN, HIGH); // set the LED on
+ delay(1000); // wait for a second
+ digitalWrite(LEDPIN, LOW); // set the LED off
+ delay(1000); // wait for a second
+}
\ No newline at end of file
diff --git a/AVR_Programmer/AVR_Programmer.pde b/AVR_Programmer/AVR_Programmer.pde
new file mode 100644
index 0000000..7057781
--- /dev/null
+++ b/AVR_Programmer/AVR_Programmer.pde
@@ -0,0 +1,286 @@
+#define PAGESIZE 32 // in (2-byte) words
+ // set to 32 for atmega8
+ // set to 64 for atmega168
+
+
+#define LED 13
+
+#define RESET 2
+#define SCK 3
+#define MISO 4
+#define MOSI 5
+
+#define CTS 6
+
+typedef unsigned char byte; // 8 bit
+typedef unsigned int word; // 16 bit
+typedef unsigned long dword; // 32 bit
+
+dword spibits(int n, byte output);
+dword spidword(dword output);
+word spiword(word output);
+byte spibyte(byte output);
+void printhex(byte x);
+void printbits(byte x);
+void waitforinput(void);
+char readchar(void);
+byte readnibble(void);
+byte readbyte(void);
+word readword(void);
+void skipline(void);
+
+
+void setup()
+{
+ pinMode(RESET, OUTPUT);
+ pinMode(SCK, OUTPUT);
+ pinMode(MISO, INPUT);
+ pinMode(MOSI, OUTPUT);
+ pinMode(CTS, OUTPUT);
+
+ digitalWrite(CTS, HIGH); // signal NOT clear to send to PC
+ Serial.begin(9600);
+ Serial.println();
+ Serial.println();
+ Serial.println("pesco's atmel-programming arduino, (c) 2009");
+ Serial.flush();
+}
+
+
+void loop()
+{
+ byte echo;
+
+ // give RESET a high pulse
+ Serial.println();
+ Serial.println("reset pulse.");
+ digitalWrite(RESET, HIGH);
+ delay(50);
+ digitalWrite(RESET, LOW);
+
+ // give chip time to init
+ delay(50);
+
+ // enter programming mode
+ Serial.print("initiate programming: ");
+ echo = (spidword(0xAC530000) & 0xFF00) >> 8;
+
+ if(echo == 0x53) {
+ byte sig[3];
+ byte lock;
+ word fuse;
+
+ Serial.println("slave confirms.");
+
+ // read signature byte
+ Serial.print("reading signature bytes: 0x");
+ sig[0] = spidword(0x30000000) & 0xFF;
+ printhex(sig[0]);
+ sig[1] = spidword(0x30000100) & 0xFF;
+ printhex(sig[1]);
+ sig[2] = spidword(0x30000200) & 0xFF;
+ printhex(sig[2]);
+ Serial.println();
+
+ // read lock bits
+ Serial.print("reading lock bits: ");
+ lock = spidword(0x58000000) & 0x3F;
+ printbits(lock);
+ Serial.println();
+
+ // read fuse bits
+ Serial.print("reading fuse bits: ");
+ fuse = (spidword(0x58080000) & 0xFF) << 8; // high byte
+ printbits(fuse >> 8);
+ fuse |= spidword(0x50000000) & 0xFF; // low byte
+ printbits(fuse & 0xFF);
+ Serial.println();
+
+ // wait for firmware image on serial
+ Serial.print("awaiting hex file...");
+ waitforinput();
+ Serial.println(" incoming...");
+
+ // perform chip erase
+ Serial.println("chip erase.");
+ spidword(0xAC800000);
+ delay(10); // WD_ERASE
+
+ // write anything that comes over serial into program mem
+ Serial.print("writing to flash memory: (pagesize ");
+ Serial.print(PAGESIZE);
+ Serial.println(" words)");
+ word addr=0;
+ byte hi=0;
+ boolean done=false;
+ word count=0;
+ while(!done) {
+ byte n; // record length
+ byte t; // record type
+
+ // read one line of the hex file
+ readchar(); // colon
+ n = readbyte(); // record length
+ readword(); // address
+ t = readbyte(); // type
+ if(t == 0) {
+ // data record
+ Serial.print(' ');
+ for(int i=0; i=0; i--)
+ {
+ digitalWrite(MOSI, (output >> i) & 1);
+ //delay(1);
+ digitalWrite(SCK, HIGH);
+ input |= digitalRead(MISO) << i;
+ //delay(1);
+ digitalWrite(SCK, LOW);
+ }
+
+ return input;
+}
+
+dword spidword(dword output)
+{
+ return spibits(32, output);
+}
+
+word spiword(word output)
+{
+ return spibits(16, (dword)output);
+}
+
+byte spibyte(byte output)
+{
+ return spibits(8, (dword)output);
+}
+
+void printhex(byte x)
+{
+ const char digits[] = "0123456789ABCDEF";
+
+ Serial.print(digits[x>>4]);
+ Serial.print(digits[x&0x0F]);
+}
+
+void printbits(byte x)
+{
+ for(int i=7; i>=0; i--)
+ Serial.print((char)('0' + ((x>>i) & 1)));
+}
+
+void waitforinput(void)
+{
+ if(! Serial.available()) {
+ // cheap-ass flow control
+ digitalWrite(CTS, LOW); // clear to send
+ while(! Serial.available())
+ ;
+ digitalWrite(CTS, HIGH); // not clear to send
+ }
+}
+
+char readchar(void)
+{
+ waitforinput();
+ return Serial.read();
+}
+
+byte readnibble(void)
+{
+ char c;
+
+ c = readchar();
+ if(c>='0' && c<='9')
+ return (c-'0');
+ else if(c>='A' && c<='F')
+ return (c-'A' + 10);
+ else if(c>='a' && c<='f')
+ return (c-'a' + 10);
+ else
+ return 0;
+}
+
+byte readbyte(void)
+{
+ byte x,y;
+
+ x = readnibble();
+ y = readnibble();
+
+ return ((x<<4) | y);
+}
+
+word readword(void)
+{
+ word x,y;
+
+ x = readbyte();
+ y = readbyte();
+
+ return ((x<<8) | y);
+}
+
+void skipline(void)
+{
+ while(readchar() != '\n');
+}
diff --git a/Blink/Blink.pde b/Blink/Blink.pde
new file mode 100644
index 0000000..1ff77a5
--- /dev/null
+++ b/Blink/Blink.pde
@@ -0,0 +1,66 @@
+void alle(int CMD)
+{
+ for(int i=0;i<8;i++) {
+ digitalWrite(i, CMD);
+ }
+}
+
+void setup()
+{
+ pinMode(0, OUTPUT);
+ pinMode(1, OUTPUT);
+ pinMode(2, OUTPUT);
+ pinMode(3, OUTPUT);
+ pinMode(4, OUTPUT);
+ pinMode(5, OUTPUT);
+ pinMode(6, OUTPUT);
+ pinMode(7, OUTPUT);
+}
+
+void loop()
+{
+ alle(HIGH);
+ delay(500);
+ alle(LOW);
+ delay(500);
+ /*
+ digitalWrite(0, HIGH);
+ delay(500);
+ digitalWrite(0, LOW);
+ delay(500);
+
+ digitalWrite(1, HIGH);
+ delay(500);
+ digitalWrite(1, LOW);
+ delay(500);
+
+ digitalWrite(2, HIGH);
+ delay(500);
+ digitalWrite(2, LOW);
+ delay(500);
+
+ digitalWrite(3, HIGH);
+ delay(500);
+ digitalWrite(3, LOW);
+ delay(500);
+
+ digitalWrite(4, HIGH);
+ delay(500);
+ digitalWrite(4, LOW);
+ delay(500);
+
+ digitalWrite(5, HIGH);
+ delay(500);
+ digitalWrite(5, LOW);
+ delay(500);
+
+ digitalWrite(6, HIGH);
+ delay(500);
+ digitalWrite(6, LOW);
+ delay(500);
+
+ digitalWrite(7, HIGH);
+ delay(500);
+ digitalWrite(7, LOW);
+ delay(500); */
+}
diff --git a/Blink/Foo.pde b/Blink/Foo.pde
new file mode 100644
index 0000000..e69de29
diff --git a/Blink2015/Blink2015.ino/Blink2015.ino.ino b/Blink2015/Blink2015.ino/Blink2015.ino.ino
new file mode 100644
index 0000000..3f42e4d
--- /dev/null
+++ b/Blink2015/Blink2015.ino/Blink2015.ino.ino
@@ -0,0 +1,29 @@
+/*
+ Blink
+ Turns on an LED on for one second, then off for one second, repeatedly.
+
+ Most Arduinos have an on-board LED you can control. On the Uno and
+ Leonardo, it is attached to digital pin 13. If you're unsure what
+ pin the on-board LED is connected to on your Arduino model, check
+ the documentation at http://www.arduino.cc
+
+ This example code is in the public domain.
+
+ modified 8 May 2014
+ by Scott Fitzgerald
+ */
+
+
+// the setup function runs once when you press reset or power the board
+void setup() {
+ // initialize digital pin 13 as an output.
+ pinMode(13, OUTPUT);
+}
+
+// the loop function runs over and over again forever
+void loop() {
+ digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
+ delay(1000); // wait for a second
+ digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
+ delay(1000); // wait for a second
+}
diff --git a/BlinkNeu/BlinkNeu.pde b/BlinkNeu/BlinkNeu.pde
new file mode 100644
index 0000000..849c990
--- /dev/null
+++ b/BlinkNeu/BlinkNeu.pde
@@ -0,0 +1,30 @@
+/*
+ Blink
+ Turns on an LED on for one second, then off for one second, repeatedly.
+
+ This example code is in the public domain.
+ */
+
+void setup() {
+Serial.begin(9600);
+ // initialize the digital pin as an output.
+ // Pin 13 has an LED connected on most Arduino boards:
+ pinMode(9, OUTPUT);
+pinMode(10, OUTPUT);
+pinMode(11, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(9, HIGH); // set the LED on
+ delay(1000); // wait for a second
+ digitalWrite(10, HIGH); // set the LED on
+ delay(1000); // wait for a second
+ digitalWrite(11, HIGH); // set the LED on
+ delay(1000); // wait for a second
+ digitalWrite(9, LOW); // set the LED on
+ delay(1000); // wait for a second
+ digitalWrite(10, LOW); // set the LED on
+ delay(1000); // wait for a second
+ digitalWrite(11, LOW); // set the LED off
+ delay(1000); // wait for a second
+}
diff --git a/Blink_GNO b/Blink_GNO
new file mode 100644
index 0000000..ecb1112
--- /dev/null
+++ b/Blink_GNO
@@ -0,0 +1,14 @@
+void setup()
+{
+ Serial.begin(9600); // USB is always 12 Mbit/sec
+}
+
+void loop()
+{
+ digitalWrite(13, HIGH);
+ Serial.println("Hello World...");
+ delay(1000);
+ digitalWrite(13, LOW);
+ Serial.println("Hello World...");
+ delay(1000);
+}
\ No newline at end of file
diff --git a/Blink_test/Blink_test.pde b/Blink_test/Blink_test.pde
new file mode 100644
index 0000000..8c7866b
--- /dev/null
+++ b/Blink_test/Blink_test.pde
@@ -0,0 +1,19 @@
+/*
+ Blink
+ Turns on an LED on for one second, then off for one second, repeatedly.
+
+ This example code is in the public domain.
+ */
+
+void setup() {
+ // initialize the digital pin as an output.
+ // Pin 13 has an LED connected on most Arduino boards:
+ pinMode(13, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(13, HIGH); // set the LED on
+ //delay(20); // wait for a second
+ //digitalWrite(13, LOW); // set the LED off
+ //delay(20); // wait for a second
+}
diff --git a/DCF77/LCD4Bit.pde b/DCF77/LCD4Bit.pde
new file mode 100644
index 0000000..5f1eabc
--- /dev/null
+++ b/DCF77/LCD4Bit.pde
@@ -0,0 +1,327 @@
+
+#include
+#include
+
+//create object to control an LCD.
+//number of lines in display=2
+LCD4Bit lcd = LCD4Bit(2);
+
+/**
+ * Where is the DCF receiver connected?
+ */
+#define DCF77PIN 6
+/**
+ * Where is the LED connected?
+ */
+#define BLINKPIN 13
+/**
+ * Turn debugging on or off
+ */
+//#define DCF_DEBUG 1
+/**
+ * Number of milliseconds to elapse before we assume a "1",
+ * if we receive a falling flank before - its a 0.
+ */
+#define DCF_split_millis 140
+/**
+ * There is no signal in second 59 - detect the beginning of
+ * a new minute.
+ */
+#define DCF_sync_millis 1200
+/**
+ * Definitions for the timer interrupt 2 handler:
+ * The Arduino runs at 16 Mhz, we use a prescaler of 64 -> We need to
+ * initialize the counter with 6. This way, we have 1000 interrupts per second.
+ * We use tick_counter to count the interrupts.
+ */
+#define INIT_TIMER_COUNT 6
+#define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT
+int tick_counter = 0;
+/**
+ * DCF time format struct
+ */
+struct DCF77Buffer {
+ unsigned long long prefix :21;
+ unsigned long long Min :7; // minutes
+ unsigned long long P1 :1; // parity minutes
+ unsigned long long Hour :6; // hours
+ unsigned long long P2 :1; // parity hours
+ unsigned long long Day :6; // day
+ unsigned long long Weekday :3; // day of week
+ unsigned long long Month :5; // month
+ unsigned long long Year :8; // year (5 -> 2005)
+ unsigned long long P3 :1; // parity
+};
+struct {
+ unsigned char parity_flag :1;
+ unsigned char parity_min :1;
+ unsigned char parity_hour :1;
+ unsigned char parity_date :1;
+} flags;
+/**
+ * Clock variables
+ */
+volatile unsigned char DCFSignalState = 0;
+unsigned char previousSignalState;
+int previousFlankTime;
+int bufferPosition;
+unsigned long long dcf_rx_buffer;
+/**
+ * time vars: the time is stored here!
+ */
+volatile unsigned char ss;
+volatile unsigned char mm;
+volatile unsigned char hh;
+volatile unsigned char day;
+volatile unsigned char mon;
+volatile unsigned int year;
+
+
+/**
+ * used in main loop: detect a new second...
+ */
+unsigned char previousSecond;
+
+/**
+ * Initialize the DCF77 routines: initialize the variables,
+ * configure the interrupt behaviour.
+ */
+void DCF77Init() {
+ previousSignalState=0;
+ previousFlankTime=0;
+ bufferPosition=0;
+ dcf_rx_buffer=0;
+ ss=mm=hh=day=mon=year=0;
+#ifdef DCF_DEBUG
+ Serial.println("Initializing DCF77 routines");
+ Serial.print("Using DCF77 pin #");
+ Serial.println(DCF77PIN);
+ pinMode(BLINKPIN, OUTPUT);
+ pinMode(DCF77PIN, INPUT);
+#endif
+ pinMode(DCF77PIN, INPUT);
+#ifdef DCF_DEBUG
+ Serial.println("Initializing timerinterrupt");
+#endif
+ //Timer2 Settings: Timer Prescaler /64,
+ TCCR2 |= (1< 59,
+ * a new minute begins -> time to call finalizeBuffer().
+ */
+void appendSignal(unsigned char signal) {
+#ifdef DCF_DEBUG
+ Serial.print(", appending value ");
+ Serial.print(signal, DEC);
+ Serial.print(" at position ");
+ Serial.println(bufferPosition);
+#endif
+ dcf_rx_buffer = dcf_rx_buffer | ((unsigned long long) signal << bufferPosition);
+ // Update the parity bits. First: Reset when minute, hour or date starts.
+ if (bufferPosition == 21 || bufferPosition == 29 || bufferPosition == 36) {
+ flags.parity_flag = 0;
+ }
+ // save the parity when the corresponding segment ends
+ if (bufferPosition == 28) {flags.parity_min = flags.parity_flag;};
+ if (bufferPosition == 35) {flags.parity_hour = flags.parity_flag;};
+ if (bufferPosition == 58) {flags.parity_date = flags.parity_flag;};
+ // When we received a 1, toggle the parity flag
+ if (signal == 1) {
+ flags.parity_flag = flags.parity_flag ^ 1;
+ }
+ bufferPosition++;
+ if (bufferPosition > 59) {
+ finalizeBuffer();
+ }
+}
+
+/**
+ * Evaluates the information stored in the buffer. This is where the DCF77
+ * signal is decoded and the internal clock is updated.
+ */
+void finalizeBuffer(void) {
+ if (bufferPosition == 59) {
+#ifdef DCF_DEBUG
+ Serial.println("Finalizing Buffer");
+#endif
+ struct DCF77Buffer *rx_buffer;
+ rx_buffer = (struct DCF77Buffer *)(unsigned long long)&dcf_rx_buffer;
+ if (flags.parity_min == rx_buffer->P1 &&
+ flags.parity_hour == rx_buffer->P2 &&
+ flags.parity_date == rx_buffer->P3)
+ {
+#ifdef DCF_DEBUG
+ Serial.println("Parity check OK - updating time.");
+#endif
+ //convert the received bits from BCD
+ mm = rx_buffer->Min-((rx_buffer->Min/16)*6);
+ hh = rx_buffer->Hour-((rx_buffer->Hour/16)*6);
+ day= rx_buffer->Day-((rx_buffer->Day/16)*6);
+ mon= rx_buffer->Month-((rx_buffer->Month/16)*6);
+ year= 2000 + rx_buffer->Year-((rx_buffer->Year/16)*6);
+ }
+#ifdef DCF_DEBUG
+ else {
+ Serial.println("Parity check NOK - running on internal clock.");
+ }
+#endif
+ }
+ // reset stuff
+ ss = 0;
+ bufferPosition = 0;
+ dcf_rx_buffer=0;
+}
+
+/**
+ * Dump the time to the serial line.
+ */
+void serialDumpTime(void){
+ Serial.print("Time: ");
+ Serial.print(hh, DEC);
+ Serial.print(":");
+ Serial.print(mm, DEC);
+ Serial.print(":");
+ Serial.print(ss, DEC);
+ Serial.print(" Date: ");
+ Serial.print(day, DEC);
+ Serial.print(".");
+ Serial.print(mon, DEC);
+ Serial.print(".");
+ Serial.println(year, DEC);
+}
+
+
+/**
+ * Evaluates the signal as it is received. Decides whether we received
+ * a "1" or a "0" based on the
+ */
+void scanSignal(void){
+ if (DCFSignalState == 1) {
+ int thisFlankTime=millis();
+ if (thisFlankTime - previousFlankTime > DCF_sync_millis) {
+#ifdef DCF_DEBUG
+ Serial.println("####");
+ Serial.println("#### Begin of new Minute!!!");
+ Serial.println("####");
+#endif
+ finalizeBuffer();
+ }
+ previousFlankTime=thisFlankTime;
+#ifdef DCF_DEBUG
+ Serial.print(previousFlankTime);
+ Serial.print(": DCF77 Signal detected, ");
+#endif
+ }
+ else {
+ /* or a falling flank */
+ int difference=millis() - previousFlankTime;
+#ifdef DCF_DEBUG
+ Serial.print("duration: ");
+ Serial.print(difference);
+#endif
+ if (difference < DCF_split_millis) {
+ appendSignal(0);
+ }
+ else {
+ appendSignal(1);
+ }
+ }
+}
+
+/**
+ * The interrupt routine for counting seconds - increment hh:mm:ss.
+ */
+ISR(TIMER2_OVF_vect) {
+ RESET_TIMER2;
+ tick_counter += 1;
+ if (tick_counter == 1000) {
+ ss++;
+ if (ss==60) {
+ ss=0;
+ mm++;
+ if (mm==60) {
+ mm=0;
+ hh++;
+ if (hh==24)
+ hh=0;
+ }
+ }
+ tick_counter = 0;
+ }
+};
+
+/**
+ * Interrupthandler for INT0 - called when the signal on Pin 2 changes.
+ */
+void int0handler() {
+ // check the value again - since it takes some time to
+ // activate the interrupt routine, we get a clear signal.
+ DCFSignalState = digitalRead(DCF77PIN);
+}
+
+
+/**
+ * Standard Arduino methods below.
+ */
+
+void setup(void) {
+
+ //pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat
+ //lcd.init();
+
+ // We need to start serial here again,
+ // for Arduino 007 (new serial code)
+ Serial.begin(9600);
+ DCF77Init();
+}
+
+void loop(void) {
+ if (ss != previousSecond) {
+ serialDumpTime();
+ previousSecond = ss;
+ }
+ if (DCFSignalState != previousSignalState) {
+ scanSignal();
+ if (DCFSignalState) {
+ digitalWrite(BLINKPIN, HIGH);
+ } else {
+ digitalWrite(BLINKPIN, LOW);
+ }
+ previousSignalState = DCFSignalState;
+ }
+ //delay(20);
+}
+
+void loop22() {
+
+ lcd.clear(); // Clear display
+
+ lcd.printIn("hallo welt!"); // Dislay text on first line
+ lcd.leftScroll(32, 200);
+ //lcd.cursorTo(2,0); // Move cursor to second line, position 0
+
+ //lcd.printIn("fuck off!"); // Display text on second line
+ /*
+ while(1) // Endless loop flashing the LED
+ {
+ digitalWrite(13, HIGH);
+ delay(1000);
+ digitalWrite(13, LOW);
+ delay(1000);
+ }
+ */
+}
diff --git a/DS1626/DS1626.ino b/DS1626/DS1626.ino
new file mode 100644
index 0000000..e495316
--- /dev/null
+++ b/DS1626/DS1626.ino
@@ -0,0 +1,143 @@
+
+//#include
+
+//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
+
+#include
+
+
+#define rxPin 0
+#define txPin 1
+#define ledPin 13
+
+#define rstPin 6
+#define clkPin 7
+#define dqPin 8
+
+#define tempPin 0
+
+// set up a new serial port
+SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
+byte pinState = 0;
+
+void setup() {
+ // define pin modes for tx, rx, led pins:
+ pinMode(rxPin, INPUT);
+ pinMode(txPin, OUTPUT);
+
+ pinMode(ledPin, OUTPUT);
+ pinMode(rstPin, OUTPUT);
+ pinMode(clkPin, OUTPUT);
+ pinMode(dqPin, OUTPUT);
+
+ // set the data rate for the SoftwareSerial port
+ mySerial.begin(9600);
+
+ //lcd.begin(16, 2);
+ //lcd.print("Temperature:");
+}
+
+
+void loop() {
+ float temp;
+
+ rst_low();
+
+ clk_high();
+ rst_high(); //all data transfer are initiated by driving RST high
+ write_command(0x0c); // write config command
+ write_command(0x02); // cpu mode
+ rst_low();
+ delay(200); //wait until the configuration register is written
+
+ clk_high();
+ rst_high();
+ write_command(0x51); //start conversion
+ rst_low();
+ delay(200);
+
+ clk_high();
+ rst_high();
+ write_command(0xAA);
+ int raw_data = read_raw_data();
+ rst_low();
+
+ mySerial.print("temperature:");
+ mySerial.print(raw_data/20);
+ mySerial.println(" C");
+
+ /*
+ temp = analogRead(tempPin);
+ //temp = temp * 0.48828125;
+ temp = (5.0 * temp * 100.0)/1024.0;
+ lcd.setCursor(0, 1);
+ lcd.print(temp);
+ //lcd.print(" ");
+ //lcd.print("wsew");
+
+
+ delay(1000);
+ */
+ delay(1000);
+
+}
+
+void write_command(int command)
+/* sends 8 bit command on DQ output, least sig bit first */
+{
+ int n, bit;
+
+ for(n=0;n<8;n++)
+ {
+ bit = ((command >> n) & (0x01));
+ out_bit(bit);
+ }
+}
+
+int read_raw_data(void)
+{
+ int bit,n;
+ int raw_data=0;
+
+ pinMode(dqPin,INPUT);
+
+ /* jam the dq lead high to use as input */
+ for(n=0;n<9;n++)
+ {
+ clk_low();
+ bit=(digitalRead(dqPin));
+ clk_high();
+ raw_data = raw_data | (bit << n);
+ }
+ pinMode(dqPin, OUTPUT);
+ return(raw_data);
+}
+
+void out_bit(int bit)
+{
+ digitalWrite(dqPin, bit); /* set up the data */
+ clk_low(); /* and then provide a clock pulse */
+ clk_high();
+}
+
+void clk_high(void)
+{
+ digitalWrite(clkPin,HIGH);
+}
+
+void clk_low(void)
+{
+ digitalWrite(clkPin,LOW);
+}
+
+void rst_high(void)
+{
+ digitalWrite(rstPin,HIGH);
+}
+
+void rst_low(void)
+{
+ digitalWrite(rstPin,LOW);
+}
+
+
diff --git a/Dimmer/Dimmer.ino b/Dimmer/Dimmer.ino
new file mode 100644
index 0000000..bda256c
--- /dev/null
+++ b/Dimmer/Dimmer.ino
@@ -0,0 +1,36 @@
+/*
+ * Dimmer
+ * by David A. Mellis
+ *
+ * Demonstrates the sending data from the computer to the Arduino board,
+ * in this case to control the brightness of an LED. The data is sent
+ * in individual bytes, each of which ranges from 0 to 255. Arduino
+ * reads these bytes and uses them to set the brightness of the LED.
+ *
+ * http://www.arduino.cc/en/Tutorial/Dimmer
+ */
+
+int ledPin = 13;
+
+void setup()
+{
+ // begin the serial communication
+ Serial.begin(9600);
+ pinMode(ledPin, OUTPUT);
+}
+
+void loop()
+{
+ byte val;
+
+ // check if data has been sent from the computer
+ if (Serial.available()) {
+ // read the most recent byte (which will be from 0 to 255)
+ val = Serial.read();
+ // set the brightness of the LED
+ analogWrite(ledPin, val);
+ //Serial.write(255);
+ Serial.write(val/2);
+ }
+
+}
diff --git a/Display_01/Display_01.pde b/Display_01/Display_01.pde
new file mode 100644
index 0000000..1e1c839
--- /dev/null
+++ b/Display_01/Display_01.pde
@@ -0,0 +1,61 @@
+/*
+ LiquidCrystal Library - display() and noDisplay()
+
+ Demonstrates the use a 16x2 LCD display. The LiquidCrystal
+ library works with all LCD displays that are compatible with the
+ Hitachi HD44780 driver. There are many of them out there, and you
+ can usually tell them by the 16-pin interface.
+
+ This sketch prints "Hello World!" to the LCD and uses the
+ display() and noDisplay() functions to turn on and off
+ the display.
+
+ The circuit:
+ * LCD RS pin to digital pin 12
+ * LCD Enable pin to digital pin 11
+ * LCD D4 pin to digital pin 5
+ * LCD D5 pin to digital pin 4
+ * LCD D6 pin to digital pin 3
+ * LCD D7 pin to digital pin 2
+ * LCD R/W pin to ground
+ * 10K resistor:
+ * ends to +5V and ground
+ * wiper to LCD VO pin (pin 3)
+
+ Library originally added 18 Apr 2008
+ by David A. Mellis
+ library modified 5 Jul 2009
+ by Limor Fried (http://www.ladyada.net)
+ example added 9 Jul 2009
+ by Tom Igoe
+ modified 22 Nov 2010
+ by Tom Igoe
+
+ This example code is in the public domain.
+
+ http://www.arduino.cc/en/Tutorial/LiquidCrystal
+ */
+
+// include the library code:
+#include
+
+// initialize the library with the numbers of the interface pins
+LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
+
+void setup() {
+ // set up the LCD's number of columns and rows:
+ lcd.begin(16, 2);
+ // Print a message to the LCD.
+ lcd.print("hello, world!");
+ delay(5000);
+}
+
+void loop() {
+ // Turn off the display:
+ lcd.noDisplay();
+ delay(500);
+ // Turn on the display:
+ lcd.display();
+ delay(500);
+}
+
diff --git a/Display_02/Display_02.pde b/Display_02/Display_02.pde
new file mode 100644
index 0000000..1a4ebbe
--- /dev/null
+++ b/Display_02/Display_02.pde
@@ -0,0 +1,79 @@
+
+#include
+
+// Connections:
+// rs (LCD pin 4) to Arduino pin 12
+// rw (LCD pin 5) to Arduino pin 11
+// enable (LCD pin 6) to Arduino pin 10
+// LCD pin 15 to Arduino pin 13
+// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
+LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
+
+#define OUTPIN 7
+#define INPIN 8
+
+void setup()
+{
+
+ pinMode(OUTPIN, OUTPUT);
+ digitalWrite(OUTPIN, LOW);
+ pinMode(INPIN, INPUT);
+ pinMode(13, OUTPUT);
+ digitalWrite(13, LOW); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
+
+
+
+
+ lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
+ lcd.clear(); // start with a blank screen
+ lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
+ lcd.print("Hej Katrin..."); // change this text to whatever you like. keep it clean.
+ lcd.setCursor(0,1); // set cursor to column 0, row 1
+ lcd.print("Jeg elsker dig!");
+
+ // if you have a 4 row LCD, uncomment these lines to write to the bottom rows
+ // and change the lcd.begin() statement above.
+ //lcd.setCursor(0,2); // set cursor to column 0, row 2
+ //lcd.print("Row 3");
+ //lcd.setCursor(0,3); // set cursor to column 0, row 3
+ //lcd.print("Row 4");
+}
+
+void loop()
+{
+ /*
+ boolean val = digitalRead(INPIN);
+
+ if(val == LOW) {
+ digitalWrite(OUTPIN, LOW);
+ digitalWrite(13, LOW);
+
+ }
+
+ if(val == HIGH) {
+ for(int i = 15; i >= 0; i--) {
+ lcd.clear();
+ lcd.setCursor(i,1);
+ lcd.print("<");
+ delay(200);
+ }
+ for(int i = 0; i <= 15; i++) {
+ lcd.clear();
+ lcd.setCursor(i,0);
+ lcd.print(">");
+ delay(200);
+ if(i == 15) {
+ lcd.clear();
+ }
+
+ }
+ digitalWrite(OUTPIN, HIGH);
+ digitalWrite(13, HIGH);
+ // delay(200);
+ }
+ */
+ //
+ ///}
+ delay(333);
+
+}
diff --git a/Fade/Fade.ino b/Fade/Fade.ino
new file mode 100644
index 0000000..6f4d53b
--- /dev/null
+++ b/Fade/Fade.ino
@@ -0,0 +1,35 @@
+/*
+ Fade
+
+ This example shows how to fade an LED on pin 9
+ using the analogWrite() function.
+
+ This example code is in the public domain.
+ */
+
+int led = 11; // the pin that the LED is attached to
+int brightness = 0; // how bright the LED is
+int fadeAmount = 5; // how many points to fade the LED by
+
+// the setup routine runs once when you press reset:
+void setup() {
+ // declare pin 9 to be an output:
+ pinMode(led, OUTPUT);
+}
+
+// the loop routine runs over and over again forever:
+void loop() {
+ // set the brightness of pin 9:
+ analogWrite(led, brightness);
+
+ // change the brightness for next time through the loop:
+ brightness = brightness + fadeAmount;
+
+ // reverse the direction of the fading at the ends of the fade:
+ if (brightness == 0 || brightness == 255) {
+ fadeAmount = -fadeAmount ;
+ }
+ // wait for 30 milliseconds to see the dimming effect
+ delay(30);
+}
+
diff --git a/FadeNeu/FadeNeu.pde b/FadeNeu/FadeNeu.pde
new file mode 100644
index 0000000..6595ec7
--- /dev/null
+++ b/FadeNeu/FadeNeu.pde
@@ -0,0 +1,43 @@
+/*
+ Fade
+
+ This example shows how to fade an LED on pin 9
+ using the analogWrite() function.
+
+ This example code is in the public domain.
+
+ */
+int brightness1 = 0; // how bright the LED is
+int brightness2 = 85; // how bright the LED is
+int brightness3 = 170; // how bright the LED is
+int fadeAmount1 = 5; // how many points to fade the LED by
+int fadeAmount2 = 5; // how many points to fade the LED by
+int fadeAmount3 = 5; // how many points to fade the LED by
+
+void setup() {
+ pinMode(9, OUTPUT);
+ pinMode(10, OUTPUT);
+ pinMode(11, OUTPUT);
+}
+
+void loop() {
+ analogWrite(9, brightness1);
+ analogWrite(10, brightness2);
+ analogWrite(11, brightness3);
+
+ brightness1 = brightness1 + fadeAmount1;
+ brightness2 = brightness2 + fadeAmount2;
+ brightness3 = brightness3 + fadeAmount3;
+
+ if (brightness1 == 0 || brightness1 == 255) {
+ fadeAmount1 = -fadeAmount1 ;
+ }
+ if (brightness2 == 0 || brightness2 == 255) {
+ fadeAmount2 = -fadeAmount2 ;
+ }
+ if (brightness3 == 0 || brightness3 == 255) {
+ fadeAmount3 = -fadeAmount3 ;
+ }
+
+ delay(250);
+}
diff --git a/Fade_test/Fade_test.pde b/Fade_test/Fade_test.pde
new file mode 100644
index 0000000..d89a3db
--- /dev/null
+++ b/Fade_test/Fade_test.pde
@@ -0,0 +1,33 @@
+/*
+ Fade
+
+ This example shows how to fade an LED on pin 9
+ using the analogWrite() function.
+
+ This example code is in the public domain.
+
+ */
+int brightness = 0; // how bright the LED is
+int fadeAmount = 5; // how many points to fade the LED by
+
+void setup() {
+ // declare pin 9 to be an output:
+ pinMode(1, OUTPUT);
+ pinMode(11, OUTPUT);
+}
+
+void loop() {
+ // set the brightness of pin 9:
+ analogWrite(1, brightness);
+ analogWrite(11, brightness);
+
+ // change the brightness for next time through the loop:
+ brightness = brightness + fadeAmount;
+
+ // reverse the direction of the fading at the ends of the fade:
+ if (brightness == 0 || brightness == 255) {
+ fadeAmount = -fadeAmount ;
+ }
+ // wait for 30 milliseconds to see the dimming effect
+ delay(30);
+}
diff --git a/LCD2015/LCD2015.ino/LCD2015.ino.ino b/LCD2015/LCD2015.ino/LCD2015.ino.ino
new file mode 100644
index 0000000..d640341
--- /dev/null
+++ b/LCD2015/LCD2015.ino/LCD2015.ino.ino
@@ -0,0 +1,29 @@
+#include
+
+LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
+
+float tempRaw;
+float tempC;
+float tempF;
+int tempPin = 0;
+
+void setup() {
+ pinMode(13, OUTPUT);
+ lcd.begin(16, 2);
+ lcd.print("Temperature:");
+}
+
+void loop() {
+ tempRaw = analogRead(tempPin);
+ tempC = tempRaw/2;
+ tempF = (tempC*9)/5 + 32;
+ lcd.setCursor(0, 1);
+ lcd.print(tempC);
+ lcd.print("C / ");
+ lcd.print(tempF);
+ lcd.print("F");
+ digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
+ delay(1000); // wait for a second
+ digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
+ delay(1000); // wait for a second
+}
diff --git a/LCD4Bit/LCD4Bit.pde b/LCD4Bit/LCD4Bit.pde
new file mode 100644
index 0000000..276ede5
--- /dev/null
+++ b/LCD4Bit/LCD4Bit.pde
@@ -0,0 +1,51 @@
+
+
+#include
+
+//create object to control an LCD.
+//number of lines in display=2
+LCD4Bit lcd = LCD4Bit(2);
+
+
+
+
+void setup(void) {
+ pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat
+ lcd.init();
+}
+
+void loop() {
+
+ lcd.clear(); // Clear display
+
+ //lcd.printIn("fuck the world guys... ?"); // Dislay text on first line
+ //lcd.leftScroll(32, 600);
+ // lcd.cursorTo(2,0); // Move cursor to second line, position 0
+
+ //lcd.printIn("<<<>>>"); // Display text on second line
+
+
+lcd.printIn("Hey guys...");
+lcd.cursorTo(2,0);
+delay(5000);
+lcd.printIn("what's up?");
+delay(5000);
+lcd.cursorTo(1,0);
+lcd.printIn("Hehehehehhe....");
+lcd.cursorTo(2,0);
+lcd.printIn(".................");
+delay(10000);
+//lcd.printIn("");
+//lcd.printIn("");
+
+delay(5000);
+/*
+ while(1) // Endless loop flashing the LED
+ {
+ digitalWrite(13, HIGH);
+ delay(1000);
+ digitalWrite(13, LOW);
+ delay(1000);
+ }
+ */
+}
diff --git a/LCD4BitExample_01/LCD4BitExample_01.pde b/LCD4BitExample_01/LCD4BitExample_01.pde
new file mode 100644
index 0000000..4f4f8e4
--- /dev/null
+++ b/LCD4BitExample_01/LCD4BitExample_01.pde
@@ -0,0 +1,47 @@
+//example use of LCD4Bit library
+
+#include
+//create object to control an LCD.
+//number of lines in display=1
+LCD4Bit lcd = LCD4Bit(2);
+
+//some messages to display on the LCD
+char msgs[6][15] = {"apple", "banana", "pineapple", "mango", "watermelon", "pear"};
+int NUM_MSGS = 6;
+
+void setup() {
+ pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat
+
+ lcd.init();
+ //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
+ //lcd.commandWrite(0x0F);//cursor on, display on, blink on. (nasty!)
+}
+
+void loop() {
+ digitalWrite(13, HIGH); //light the debug LED
+
+ //pick a random message from the array
+ int pick = random(NUM_MSGS);
+ char* msg = msgs[pick];
+
+ lcd.clear();
+ lcd.printIn(msg);
+ delay(1000);
+ digitalWrite(13, LOW);
+
+ //print some dots individually
+ for (int i=0; i<3; i++){
+ lcd.print('.');
+ delay(100);
+ }
+ //print something on the display's second line.
+ //uncomment this if your display HAS two lines!
+ /*
+ lcd.cursorTo(2, 0); //line=2, x=0.
+ lcd.printIn("Score: 6/7");
+ delay(1000);
+ */
+
+ //scroll entire display 20 chars to left, delaying 50ms each inc
+ lcd.leftScroll(20, 50);
+}
diff --git a/Motion_Sensor/Motion_Sensor.pde b/Motion_Sensor/Motion_Sensor.pde
new file mode 100644
index 0000000..b1528b4
--- /dev/null
+++ b/Motion_Sensor/Motion_Sensor.pde
@@ -0,0 +1,29 @@
+
+
+
+int buttonState = 0;
+
+void setup() {
+
+ Serial.begin(9600);
+
+
+ pinMode(7, INPUT);
+ pinMode(13, OUTPUT);
+}
+
+void loop() {
+
+
+
+ buttonState = digitalRead(7);
+
+ if (buttonState == HIGH) {
+ digitalWrite(13, HIGH);
+ }
+ else {
+ digitalWrite(13, LOW);
+ }
+ Serial.println(buttonState, DEC);
+ delay(1000); // wait for a second
+}
diff --git a/README.md b/README.md
index 961a785..b065fc3 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,8 @@
-# arduino
-All my Arduino stuff.
+arduino
+=======
+
+All my Arduino stuff. Most files are many years old because I didn't hacked on
+Arduino for long time. Many files are just garbage and will be deleted at some
+time. I will try to make this repository clean ASAP. Currently I only need it
+for sharing my Arduino code between my devices. I recommend not to use this
+code actually.... ;)
diff --git a/Relais/Relais.pde b/Relais/Relais.pde
new file mode 100644
index 0000000..18459e0
--- /dev/null
+++ b/Relais/Relais.pde
@@ -0,0 +1,15 @@
+
+int ledPin = 13; // LED connected to digital pin 13
+
+void setup() // run once, when the sketch starts
+{
+ pinMode(ledPin, OUTPUT); // sets the digital pin as output
+}
+
+void loop() // run over and over again
+{
+ digitalWrite(ledPin, HIGH); // sets the LED on
+ delay(1000); // waits for a second
+ digitalWrite(ledPin, LOW); // sets the LED off
+ delay(1000); // waits for a second
+}
diff --git a/ShiftRegister_1/ShiftRegister_1.pde b/ShiftRegister_1/ShiftRegister_1.pde
new file mode 100644
index 0000000..06c822e
--- /dev/null
+++ b/ShiftRegister_1/ShiftRegister_1.pde
@@ -0,0 +1,32 @@
+
+int pin_led_clock=2;
+int pin_led_latch=3;
+int pin_led_data=4;
+
+void setup() {
+ Serial.begin(9600); //start serial
+ pinMode(pin_led_data, OUTPUT);
+ pinMode(pin_led_latch, OUTPUT);
+ pinMode(pin_led_clock, OUTPUT);
+}
+
+void loop() {
+ set_led_states(LOW);
+ delay(500);
+ set_led_states(HIGH);
+ delay(500);
+}
+
+void set_led_states(int CMD){
+ for (int n=0; n<8; n++) {
+ digitalWrite(pin_led_data, CMD); // turn the 'current' led on
+ pulse_pin(pin_led_clock); // address the next bit slot
+ }
+ pulse_pin(pin_led_latch); // when the latch goes from low to high, the data that's been stored to the register's memory gets sent to its output pins
+}
+
+// Set a pin to low, then high
+void pulse_pin(int pin_number){
+ digitalWrite(pin_number,LOW);
+ digitalWrite(pin_number,HIGH);
+}
diff --git a/Shift_Register_01/Shift_Register_01.pde b/Shift_Register_01/Shift_Register_01.pde
new file mode 100644
index 0000000..eacefb6
--- /dev/null
+++ b/Shift_Register_01/Shift_Register_01.pde
@@ -0,0 +1,44 @@
+//**************************************************************//
+// Name : shiftOutCode, Hello World
+// Author : Carlyn Maw,Tom Igoe, David A. Mellis
+// Date : 25 Oct, 2006
+// Modified: 23 Mar 2010
+// Version : 2.0
+// Notes : Code for using a 74HC595 Shift Register //
+// : to count from 0 to 255
+//****************************************************************
+
+//Pin connected to ST_CP of 74HC595
+int latchPin = 8;
+//Pin connected to SH_CP of 74HC595
+int clockPin = 12;
+////Pin connected to DS of 74HC595
+int dataPin = 11;
+
+
+
+void setup() {
+ //set pins to output so you can control the shift register
+ pinMode(latchPin, OUTPUT);
+ pinMode(clockPin, OUTPUT);
+ pinMode(dataPin, OUTPUT);
+}
+
+void loop() {
+
+ for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
+ digitalWrite(latchPin, LOW);
+ shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);
+ digitalWrite(latchPin, HIGH);
+ delay(300);
+ }
+
+ for (int numberToDisplay = 255; numberToDisplay >= 0; numberToDisplay--) {
+ digitalWrite(latchPin, LOW);
+ shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);
+ digitalWrite(latchPin, HIGH);
+ delay(300);
+ }
+}
+
+
diff --git a/Shift_Register_02/Shift_Register_02.pde b/Shift_Register_02/Shift_Register_02.pde
new file mode 100644
index 0000000..a8aba3c
--- /dev/null
+++ b/Shift_Register_02/Shift_Register_02.pde
@@ -0,0 +1,68 @@
+/*
+ Shift Register Example
+ for 74HC595 shift register
+
+ This sketch turns reads serial input and uses it to set the pins
+ of a 74HC595 shift register.
+
+ Hardware:
+ * 74HC595 shift register attached to pins 2, 3, and 4 of the Arduino,
+ as detailed below.
+ * LEDs attached to each of the outputs of the shift register
+
+ Created 22 May 2009
+ Created 23 Mar 2010
+ by Tom Igoe
+
+ */
+
+//Pin connected to latch pin (ST_CP) of 74HC595
+const int latchPin = 8;
+//Pin connected to clock pin (SH_CP) of 74HC595
+const int clockPin = 12;
+////Pin connected to Data in (DS) of 74HC595
+const int dataPin = 11;
+
+void setup() {
+ //set pins to output because they are addressed in the main loop
+ pinMode(latchPin, OUTPUT);
+ pinMode(dataPin, OUTPUT);
+ pinMode(clockPin, OUTPUT);
+ Serial.begin(9600);
+ Serial.println("reset");
+}
+
+void loop() {
+ if (Serial.available() > 0) {
+ // ASCII '0' through '9' characters are
+ // represented by the values 48 through 57.
+ // so if the user types a number from 0 through 9 in ASCII,
+ // you can subtract 48 to get the actual value:
+ int bitToSet = Serial.read() - 48;
+
+ // write to the shift register with the correct bit set high:
+ registerWrite(bitToSet, HIGH);
+ }
+}
+
+// This method sends bits to the shift register:
+
+void registerWrite(int whichPin, int whichState) {
+// the bits you want to send
+ byte bitsToSend = 0;
+
+ // turn off the output so the pins don't light up
+ // while you're shifting bits:
+ digitalWrite(latchPin, LOW);
+
+ // turn on the next highest bit in bitsToSend:
+ bitWrite(bitsToSend, whichPin, whichState);
+
+ // shift the bits out:
+ shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend);
+
+ // turn on the output so the LEDs can light up:
+ digitalWrite(latchPin, HIGH);
+
+}
+
diff --git a/Temp/Temp.pde b/Temp/Temp.pde
new file mode 100644
index 0000000..1e73dc2
--- /dev/null
+++ b/Temp/Temp.pde
@@ -0,0 +1,113 @@
+
+
+#include
+
+#define BUTTON1 2
+#define BUTTON2 3
+
+// ds1621 has 0x9(b1001) A0 A1 A2
+#define DS1621_ADDR ((0x9 << 3) | 0x00)
+
+// start up ds1621
+void ds1621_init()
+{
+
+ Serial.print(DS1621_ADDR, HEX);
+ // write 0x2 to config register 0xac
+ Wire.beginTransmission(DS1621_ADDR);
+ Wire.send(0xac);
+ Wire.send(0x02);
+ Wire.endTransmission();
+ delay(20);
+
+ // tell the ds1621 to start measuring temperature
+ Wire.beginTransmission(DS1621_ADDR);
+ Wire.send(0xEE);
+ Wire.endTransmission();
+}
+
+// read temperature
+unsigned int ds161_read_temp()
+{
+ unsigned int data;
+
+ // tell ds1621 that we want to read register 0xaa (the temperature is in there)
+ Wire.beginTransmission(DS1621_ADDR);
+ Wire.send(0xaa);
+ Wire.endTransmission();
+
+ // start reading the 2 bytes of temp data
+ Wire.beginTransmission(DS1621_ADDR);
+ Wire.requestFrom(DS1621_ADDR, 2);
+ if(Wire.available())
+ data = Wire.receive() << 8;
+ if(Wire.available())
+ data |= Wire.receive();
+ return data;
+}
+
+// format and output the temperature read from a ds1621
+void ds1621_print_temp(int temp)
+{
+ if(temp & 0x8000)
+ Serial.print("-");
+ else
+ Serial.print("");
+ temp &= 0x7fff;
+ Serial.print(temp >> 8);
+ if(temp & 0xff)
+ Serial.print(",5");
+ else
+ Serial.print(",0");
+ Serial.print("\n");
+ delay(1000);
+}
+int a = 0;
+// this function is called everytime button1 is pressed
+void button1_isr(void)
+{
+// Serial.print("button1\n");
+ a= 1;
+}
+
+// this function is called everytime button2 is pressed
+void button2_isr(void)
+{
+ //Serial.print("button2\n");
+ a=2;
+}
+
+void setup()
+{
+
+ pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat
+
+ // start serial
+ Serial.begin(9600);
+
+ // start i2c
+ Wire.begin();
+
+ // start thermometer
+ ds1621_init();
+
+ // setup button gpio
+ // gpio is input and internal pullup enabled
+ pinMode(BUTTON1, INPUT);
+ pinMode(BUTTON2, INPUT);
+ digitalWrite(BUTTON1, HIGH);
+ digitalWrite(BUTTON2, HIGH);
+
+ // give both buttons an interrupt handler
+ attachInterrupt(0, button1_isr, FALLING);
+ attachInterrupt(1, button2_isr, FALLING);
+ interrupts();
+}
+
+void loop()
+{
+
+ int temp = ds161_read_temp();
+ ds1621_print_temp(temp);
+ delay(1000);
+}
diff --git a/Temp2/Temp2.pde b/Temp2/Temp2.pde
new file mode 100644
index 0000000..b4a0aec
--- /dev/null
+++ b/Temp2/Temp2.pde
@@ -0,0 +1,48 @@
+#include
+
+// ds1621 has 0x9(b1001) A0 A1 A2
+//#define DS1621_ADDR 72
+#define DS1621_ADDR ((0x9 << 3) | 0x00)
+
+void setup()
+{
+ // start serial
+ Serial.begin(9600);
+
+ // write 0x2 to config register 0xac
+ Wire.begin(DS1621_ADDR);
+ Wire.send(0xac);
+ Wire.send(0x02);
+
+ delay(20);
+
+ // tell the ds1621 to start measuring temperature
+ Wire.send(0xee);
+
+ // tell ds1621 that we want to read register
+ // 0xaa (the temperature is in there)
+ Wire.send(0xaa);
+}
+
+void loop()
+{
+ unsigned int data;
+
+ // start reading the 2 bytes of temp data
+ Wire.requestFrom(DS1621_ADDR, 2);
+
+ if(Wire.available())
+ data = Wire.receive() << 8;
+ if(Wire.available())
+ data |= Wire.receive();
+
+ Serial.print(data >> 8);
+
+ if(data & 0xff)
+ Serial.print(",5");
+ else
+ Serial.print(",0");
+
+ Serial.println("");
+ delay(1000);
+}
diff --git a/Temp_03/Temp_03.pde b/Temp_03/Temp_03.pde
new file mode 100644
index 0000000..87c6f07
--- /dev/null
+++ b/Temp_03/Temp_03.pde
@@ -0,0 +1,15 @@
+float temp;
+int tempPin = 0;
+
+void setup()
+{
+ Serial.begin(9600);
+}
+
+void loop()
+{
+ temp = analogRead(tempPin);
+ temp = temp * 0.48828125;
+ Serial.println(temp);
+ delay(1000);
+}
diff --git a/WebClient/WebClient.pde b/WebClient/WebClient.pde
new file mode 100644
index 0000000..b1ecca7
--- /dev/null
+++ b/WebClient/WebClient.pde
@@ -0,0 +1,71 @@
+/*
+ Web client
+
+ This sketch connects to a website (http://www.google.com)
+ using an Arduino Wiznet Ethernet shield.
+
+ Circuit:
+ * Ethernet shield attached to pins 10, 11, 12, 13
+
+ created 18 Dec 2009
+ by David A. Mellis
+
+ */
+
+#include
+#include
+
+// Enter a MAC address and IP address for your controller below.
+// The IP address will be dependent on your local network:
+byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+byte ip[] = { 192,168,1,23 };
+byte server[] = { 87,230,87,117 };
+
+// Initialize the Ethernet client library
+// with the IP address and port of the server
+// that you want to connect to (port 80 is default for HTTP):
+Client client(server, 80);
+
+void setup() {
+ // start the Ethernet connection:
+ Ethernet.begin(mac, ip);
+ // start the serial library:
+ Serial.begin(9600);
+ // give the Ethernet shield a second to initialize:
+ delay(1000);
+ Serial.println("connecting...");
+
+ // if you get a connection, report back via serial:
+ if (client.connect()) {
+ Serial.println("connected");
+ // Make a HTTP request:
+ client.println("GET /search?q=arduino HTTP/1.0");
+ client.println();
+ }
+ else {
+ // kf you didn't get a connection to the server:
+ Serial.println("connection failed");
+ }
+}
+
+void loop()
+{
+ // if there are incoming bytes available
+ // from the server, read them and print them:
+ if (client.available()) {
+ char c = client.read();
+ Serial.print(c);
+ }
+
+ // if the server's disconnected, stop the client:
+ if (!client.connected()) {
+ Serial.println();
+ Serial.println("disconnecting.");
+ client.stop();
+
+ // do nothing forevermore:
+ for(;;)
+ ;
+ }
+}
+
diff --git a/WebServer/WebServer.pde b/WebServer/WebServer.pde
new file mode 100644
index 0000000..14c2e9e
--- /dev/null
+++ b/WebServer/WebServer.pde
@@ -0,0 +1,82 @@
+/*
+ Web Server
+
+ A simple web server that shows the value of the analog input pins.
+ using an Arduino Wiznet Ethernet shield.
+
+ Circuit:
+ * Ethernet shield attached to pins 10, 11, 12, 13
+ * Analog inputs attached to pins A0 through A5 (optional)
+
+ created 18 Dec 2009
+ by David A. Mellis
+ modified 4 Sep 2010
+ by Tom Igoe
+
+ */
+
+#include
+#include
+
+// Enter a MAC address and IP address for your controller below.
+// The IP address will be dependent on your local network:
+byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+byte ip[] = { 192,168,1, 20 };
+
+// Initialize the Ethernet server library
+// with the IP address and port you want to use
+// (port 80 is default for HTTP):
+Server server(80);
+
+void setup()
+{
+ // start the Ethernet connection and the server:
+ Ethernet.begin(mac, ip);
+ server.begin();
+}
+
+void loop()
+{
+ // listen for incoming clients
+ Client client = server.available();
+ if (client) {
+ // an http request ends with a blank line
+ boolean currentLineIsBlank = true;
+ while (client.connected()) {
+ if (client.available()) {
+ char c = client.read();
+ // if you've gotten to the end of the line (received a newline
+ // character) and the line is blank, the http request has ended,
+ // so you can send a reply
+ if (c == '\n' && currentLineIsBlank) {
+ // send a standard http response header
+ client.println("HTTP/1.1 200 OK");
+ client.println("Content-Type: text/html");
+ client.println();
+
+ // output the value of each analog input pin
+ for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
+ client.print("analog input ");
+ client.print(analogChannel);
+ client.print(" is ");
+ client.print(analogRead(analogChannel));
+ client.println(" ");
+ }
+ break;
+ }
+ if (c == '\n') {
+ // you're starting a new line
+ currentLineIsBlank = true;
+ }
+ else if (c != '\r') {
+ // you've gotten a character on the current line
+ currentLineIsBlank = false;
+ }
+ }
+ }
+ // give the web browser time to receive the data
+ delay(1);
+ // close the connection:
+ client.stop();
+ }
+}
diff --git a/_0001_delay/_0001_delay.ino b/_0001_delay/_0001_delay.ino
new file mode 100644
index 0000000..81eb85a
--- /dev/null
+++ b/_0001_delay/_0001_delay.ino
@@ -0,0 +1,14 @@
+void setup()
+{
+ Serial.begin(9600); // USB is always 12 Mbit/sec
+}
+
+void loop()
+{
+ digitalWrite(13, HIGH);
+ Serial.println("Hello World...");
+ delay(1000);
+ digitalWrite(13, LOW);
+ //Serial.println("Hello World...");
+ delay(1000);
+}
diff --git a/_0002_delay/_0002_delay.pde b/_0002_delay/_0002_delay.pde
new file mode 100644
index 0000000..003566f
--- /dev/null
+++ b/_0002_delay/_0002_delay.pde
@@ -0,0 +1,18 @@
+/*
+ Blink
+ Turns on an LED on for one second, then off for one second, repeatedly.
+
+ This example code is in the public domain.
+ */
+
+void setup() {
+ Serial.begin(9600);
+ pinMode(13, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(13, HIGH); // set the LED on
+ delay(1000); // wait for a second
+ digitalWrite(13, LOW); // set the LED off
+ delay(1000); // wait for a second
+}
diff --git a/_74HC238/_74HC238.pde b/_74HC238/_74HC238.pde
new file mode 100644
index 0000000..e7db891
--- /dev/null
+++ b/_74HC238/_74HC238.pde
@@ -0,0 +1,27 @@
+
+void setup() {
+ Serial.begin(9600);
+ pinMode(11, OUTPUT);
+ pinMode(12, OUTPUT);
+ pinMode(13, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(11, LOW);
+ digitalWrite(12, LOW);
+ digitalWrite(13, LOW);
+
+ delay(100);
+
+ digitalWrite(11, HIGH);
+ digitalWrite(12, LOW);
+ digitalWrite(13, LOW);
+
+ delay(100);
+
+ digitalWrite(11, LOW);
+ digitalWrite(12, HIGH);
+ digitalWrite(13, LOW);
+
+ delay(100);
+}
diff --git a/_7segment/_7segment.ino b/_7segment/_7segment.ino
new file mode 100644
index 0000000..f957297
--- /dev/null
+++ b/_7segment/_7segment.ino
@@ -0,0 +1,33 @@
+/*
+ Blink
+ Turns on an LED on for one second, then off for one second, repeatedly.
+
+ This example code is in the public domain.
+ */
+
+void setup() {
+ Serial.begin(9600);
+ // initialize the digital pin as an output.
+ // Pin 13 has an LED connected on most Arduino boards:
+ pinMode(13, OUTPUT);
+ pinMode(12, OUTPUT);
+ pinMode(11, OUTPUT);
+ pinMode(10, OUTPUT);
+ pinMode(9, OUTPUT);
+ pinMode(8, OUTPUT);
+ pinMode(7, OUTPUT);
+ pinMode(6, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(13, LOW); // set the LED on
+ digitalWrite(12, HIGH); // set the LED on
+ digitalWrite(11, LOW); // set the LED on
+ digitalWrite(10, HIGH); // set the LED on
+ digitalWrite(9, LOW); // set the LED on
+ digitalWrite(8, LOW); // set the LED on
+ digitalWrite(7, LOW); // set the LED on
+ digitalWrite(6, LOW); // set the LED on
+
+
+}
diff --git a/_LT1025_temp_sensor/_LT1025_temp_sensor.ino b/_LT1025_temp_sensor/_LT1025_temp_sensor.ino
new file mode 100644
index 0000000..471607c
--- /dev/null
+++ b/_LT1025_temp_sensor/_LT1025_temp_sensor.ino
@@ -0,0 +1,21 @@
+int sensorPin = A0;
+int ledPin = 13;
+int sensorValue = 0;
+float printValue = 0;
+
+void setup() {
+ Serial.begin(9600);
+ pinMode(ledPin, OUTPUT);
+}
+
+void loop() {
+ sensorValue = analogRead(sensorPin);
+
+ printValue = (sensorValue * 0.48828125);
+
+ Serial.print(printValue);
+ Serial.print("\n");
+ digitalWrite(ledPin, HIGH);
+ delay(1000);
+ digitalWrite(ledPin, LOW);
+}
diff --git a/etherShield_ping/etherShield_ping.pde b/etherShield_ping/etherShield_ping.pde
new file mode 100644
index 0000000..4fa27ee
--- /dev/null
+++ b/etherShield_ping/etherShield_ping.pde
@@ -0,0 +1,87 @@
+#include "etherShield.h"
+
+// please modify the following two lines. mac and ip have to be unique
+// in your local area network. You can not have the same numbers in
+// two devices:
+static uint8_t mymac[6] = {
+ 0x54,0x55,0x58,0x10,0x00,0x24};
+static uint8_t myip[4] = {
+ 192,168,1,20};
+// how did I get the mac addr? Translate the first 3 numbers into ascii is: TUX
+
+#define BUFFER_SIZE 250
+unsigned char buf[BUFFER_SIZE+1];
+
+uint16_t plen;
+
+EtherShield es=EtherShield();
+
+
+void setup(){
+
+
+
+ /*initialize enc28j60*/
+ es.ES_enc28j60Init(mymac);
+ es.ES_enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz
+
+ delay(10);
+
+ /* Magjack leds configuration, see enc28j60 datasheet, page 11 */
+ // LEDA=green LEDB=yellow
+ //
+ // 0x880 is PHLCON LEDB=on, LEDA=on
+ // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);
+ es.ES_enc28j60PhyWrite(PHLCON,0x880);
+ delay(500);
+
+ //
+ // 0x990 is PHLCON LEDB=off, LEDA=off
+ // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);
+ es.ES_enc28j60PhyWrite(PHLCON,0x990);
+ delay(500);
+
+ //
+ // 0x880 is PHLCON LEDB=on, LEDA=on
+ // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);
+ es.ES_enc28j60PhyWrite(PHLCON,0x880);
+ delay(500);
+
+ //
+ // 0x990 is PHLCON LEDB=off, LEDA=off
+ // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);
+ es.ES_enc28j60PhyWrite(PHLCON,0x990);
+ delay(500);
+
+ //
+ // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
+ // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10);
+ es.ES_enc28j60PhyWrite(PHLCON,0x476);
+ delay(100);
+
+ //init the ethernet/ip layer:
+ es.ES_init_ip_arp_udp_tcp(mymac,myip,80);
+
+
+}
+
+void loop(){
+
+ plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);
+
+ /*plen will be unequal to zero if there is a valid packet (without crc error) */
+ if(plen!=0){
+ if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){
+ es.ES_make_arp_answer_from_request(buf);
+ }
+ // check if ip packets (icmp or udp) are for us:
+ if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)!=0){
+ if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){
+ // a ping packet, let's send pong
+
+ es.ES_make_echo_reply_from_request(buf,plen);
+ }
+ }
+
+ }
+}
diff --git a/etherShield_web_temperature/etherShield_web_temperature.pde b/etherShield_web_temperature/etherShield_web_temperature.pde
new file mode 100644
index 0000000..6f138ca
--- /dev/null
+++ b/etherShield_web_temperature/etherShield_web_temperature.pde
@@ -0,0 +1,221 @@
+#include "etherShield.h"
+
+// please modify the following two lines. mac and ip have to be unique
+// in your local area network. You can not have the same numbers in
+// two devices:
+static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x24};
+static uint8_t myip[4] = {192,168,1,20};
+static char baseurl[]="http://192.168.1.15/";
+static uint16_t mywwwport =80; // listen port for tcp/www (max range 1-254)
+// or on a different port:
+//static char baseurl[]="http://10.0.0.24:88/";
+//static uint16_t mywwwport =88; // listen port for tcp/www (max range 1-254)
+//
+
+int buttonState = 0;
+
+#define BUFFER_SIZE 500
+static uint8_t buf[BUFFER_SIZE+1];
+#define STR_BUFFER_SIZE 22
+static char strbuf[STR_BUFFER_SIZE+1];
+
+EtherShield es=EtherShield();
+
+// prepare the webpage by writing the data to the tcp send buffer
+uint16_t print_webpage(uint8_t *buf);
+int8_t analyse_cmd(char *str);
+// get current temperature
+#define TEMP_PIN 3
+void getCurrentTemp( int *sign, int *whole, int *fract);
+
+void setup(){
+
+ pinMode(7, INPUT);
+ pinMode(2, OUTPUT);
+
+ /*initialize enc28j60*/
+ es.ES_enc28j60Init(mymac);
+ es.ES_enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz
+ delay(10);
+
+ /* Magjack leds configuration, see enc28j60 datasheet, page 11 */
+ // LEDA=greed LEDB=yellow
+ //
+ // 0x880 is PHLCON LEDB=on, LEDA=on
+ // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);
+ es.ES_enc28j60PhyWrite(PHLCON,0x880);
+ delay(500);
+ //
+ // 0x990 is PHLCON LEDB=off, LEDA=off
+ // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);
+ es.ES_enc28j60PhyWrite(PHLCON,0x990);
+ delay(500);
+ //
+ // 0x880 is PHLCON LEDB=on, LEDA=on
+ // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);
+ es.ES_enc28j60PhyWrite(PHLCON,0x880);
+ delay(500);
+ //
+ // 0x990 is PHLCON LEDB=off, LEDA=off
+ // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);
+ es.ES_enc28j60PhyWrite(PHLCON,0x990);
+ delay(500);
+ //
+ // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
+ // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10);
+ es.ES_enc28j60PhyWrite(PHLCON,0x476);
+ delay(100);
+
+ //init the ethernet/ip layer:
+ es.ES_init_ip_arp_udp_tcp(mymac,myip,80);
+
+ // initialize DS18B20 datapin
+ digitalWrite(TEMP_PIN, LOW);
+ pinMode(TEMP_PIN, INPUT); // sets the digital pin as input (logic 1)
+
+
+}
+
+void loop(){
+ uint16_t plen, dat_p;
+ int8_t cmd;
+
+ plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);
+
+ /*plen will ne unequal to zero if there is a valid packet (without crc error) */
+ if(plen!=0){
+
+ // arp is broadcast if unknown but a host may also verify the mac address by sending it to a unicast address.
+ if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){
+ es.ES_make_arp_answer_from_request(buf);
+ return;
+ }
+
+ // check if ip packets are for us:
+ if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)==0){
+ return;
+ }
+
+ if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){
+ es.ES_make_echo_reply_from_request(buf,plen);
+ return;
+ }
+
+ // tcp port www start, compare only the lower byte
+ if (buf[IP_PROTO_P]==IP_PROTO_TCP_V&&buf[TCP_DST_PORT_H_P]==0&&buf[TCP_DST_PORT_L_P]==mywwwport){
+ if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){
+ es.ES_make_tcp_synack_from_syn(buf); // make_tcp_synack_from_syn does already send the syn,ack
+ return;
+ }
+ if (buf[TCP_FLAGS_P] & TCP_FLAGS_ACK_V){
+ es.ES_init_len_info(buf); // init some data structures
+ dat_p=es.ES_get_tcp_data_pointer();
+ if (dat_p==0){ // we can possibly have no data, just ack:
+ if (buf[TCP_FLAGS_P] & TCP_FLAGS_FIN_V){
+ es.ES_make_tcp_ack_from_any(buf);
+ }
+ return;
+ }
+ if (strncmp("GET ",(char *)&(buf[dat_p]),4)!=0){
+ // head, post and other methods for possible status codes see:
+ // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
+ plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n
-- Put your ARDUINO online -- "));
+ plen=es.ES_fill_tcp_data_p(buf,plen,PSTR(" Control digital outputs "));
+ plen=es.ES_fill_tcp_data_p(buf,plen,PSTR(" Read digital analog inputs HERE "));
+ plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("