#include #include byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //mac address byte ip[] = { xxx, xxx, xxx, xxx }; //local ip byte server[] = { xxx, xxx, xxx, xxx }; // server ip byte subnet[] = {xxx,xxx,xxx,xxx}; byte gateway[] = {xxx,xxx,xxx,xxx}; char end =0; //latest number recieved from script Client client(server, 80); //Pin connected to Pin 12 of 74HC595 (Latch) int latchPin = 2; //Pin connected to Pin 11 of 74HC595 (Clock) int clockPin = 3; //Pin connected to Pin 14 of 74HC595 (Data) int dataPin = 4; uint8_t led[8]; void setup() { //set pins to output pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); //set display to zero led[0] = B00000000; led[1] = B00000000; led[2] = B00000000; led[3] = B00000000; led[4] = B00000000; led[5] = B00000000; led[6] = B00000000; led[7] = B00000000; //start serial and ethernet Serial.begin(9600); Ethernet.begin(mac, ip, gateway, subnet); //start timer Timer1.initialize(10000); Timer1.attachInterrupt(screenUpdate); } void loop() { //connect to php script if (client.connect()) { //give some feedback Serial.println("connected"); client.println("GET /twitterpop/ HTTP/1.0"); client.println(); } delay(100); //wait to allow proper connection if (client.available()) { while(client.available()) //download all page { char c = client.read(); //Serial.print(c); end = c; } Serial.print(end); client.stop(); } int inByte = /*Serial.read();*/end; //store last character /*convert from asci to binary*/ if (inByte == 48) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0]= B00000000; } else if(inByte == 49) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0] = B10000000; } else if(inByte == 50) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0] = B11000000; } else if(inByte == 51) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0] = B11100000; } else if(inByte == 52) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0] = B11110000; } else if(inByte == 53) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0] = B11111000; } else if(inByte == 54) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0] = B11111100; } else if(inByte == 55) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0] = B11111110; } else if(inByte == 56) { for(int no=7;no>0;) { led[no]=led[no-1]; no=no-1; } led[0] = B11111111; } delay(3000); //delay before updating Serial.print("loop\n"); } void screenUpdate() { uint8_t row = B00000001; for (byte k = 0; k < 9; k++) { // Open up the latch ready to receive data digitalWrite(latchPin, LOW); shiftIt(~row ); shiftIt(led[k] ); // LED array // Close the latch, sending the data in the registers out to the //matrix digitalWrite(latchPin, HIGH); row = row << 1; } } void shiftIt(byte dataOut) { // Shift out 8 bits LSB first, // on rising edge of clock boolean pinState; //clear shift register read for sending data digitalWrite(dataPin, LOW); // for each bit in dataOut send out a bit for (int i=0; i<8; i++) { //set clockPin to LOW prior to sending bit digitalWrite(clockPin, LOW); // if the value of DataOut and (logical AND) a bitmask // are true, set pinState to 1 (HIGH) if ( dataOut & (1<