February 18, 2015

Radio Shack

I'm sure most of you know that Radio Shack is officially going out of business. Most stores have everything marked down from 50-80% off (See if your local store is listed). I have been stocking up on a boatload of Arduino Shields. I'm talking $2.00-$4.00 each. I grabbed a bunch of Ethernet, Sd-Card, Motor Controller & GMRS shields and other misc stuff i needed for projects i'm working on. Keep checking your local Radio Shack because they are getting shipments daily of more items. It might be stripped clean one day and fully stocked the next.

The shields i purchased are made by SeeedStudio. They are very high quality. The Ethernet shield does not come with the header pins on the top (for stacking) so i needed to cut mine to size and solder them.(2 rows of 6 pins & 2 rows of 8 pins). This is not so i can stack the shields. The Ethernet jack will block anything from accessing the pins. I will only use this with jumper wires.



I have been working on a project that connects my Arduino Uno & Ethernet shield to my scanner feed and it will tell me if my feed is online and how many users are currently listening to my feed. Everything is working code wise but i want to take it up a notch and attach a LCD so i can see it outside of the Arduino serial monitor. (Code Below).

One issue i will have is that when i wire up the LCD i will have to change the pins settings in Hardware and software. That wont be a problem because i wont be stacking anything on top of the Ethernet shield. The Ethernet shield uses the following pins. I marked it on the Uno to the left.

D2 - Connects the INT pin of the W5100
D3 - Contral the reset of the W5100
D10 - Used for SPI Chip Select
D11 - Used for SPI MOSI
D12 - Used for SPI MISO
D13 - Used for SPI SCK








Everything else is available. So i will need to replace the following for the LCD to work

FROM: LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

TO:
int RS = 9;
int E = 8;
int D4 = 7;
int D5 = 6;
int D6 = 5;
int D7 = 4;
LiquidCrystal lcd(RS, E, D4, D5, D6, D7 );
I will be working on this over the weekend and will let you guys now if this is an EPIC fais or a thumbs up.

Now go watch the new fight comp of the month on World Star :)




  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x04
};
// fill in an available IP address on your network here,
// for manual configuration:
//IPAddress ip(192, 168, 1, 177);

// fill in your Domain Name Server address here:
// IPAddress myDns(71,250,0,12);

// initialize the library instance:
EthernetClient client;

char server[] = "api.broadcastify.com";

unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
//const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds, 10 seconds
// the "L" is needed to use long type numbers
const unsigned long postingInterval = 5000; // delay between updates, in milliseconds, 5 seconds


String result;
String listeners_string;
int listeners;
char status = 0;
boolean last = 0;
boolean updating = 1;
boolean connection_status = 0;


void setup() {
// start serial port:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

// give the ethernet module time to boot up:
delay(1000);
// start the Ethernet connection using a fixed IP address and DNS server:
// Ethernet.begin(mac, ip, myDns);
// Remove the next four lines if you wish to hardcode the IP and DNS entries.
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
while(true);
}
// print the Ethernet board/shield's IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
delay(1000);
}

void loop() {
// if there's incoming data from the net connection.
// send it out the serial port. This is for debugging
// purposes only:
if (client.available()) {
char c = client.read();
// Serial.write(c);
result = result + c;
if(result.endsWith("online\">"))
{
result="";
updating = 0;
}

if(result.endsWith("Online"))
{
result="";
status = 1;
}

if(result.endsWith("listeners\">"))
{
result="";
last = 1;
}

if (last == 1) {
if(result.endsWith("</span>")) {
listeners_string = result.substring(0, (result.length() - 7));
last = 0;
result="";
}
}

}
else {
}


// if delay value (postingInterval) has passed since your last connection,
// then connect again and send data:

if (millis() - lastConnectionTime > postingInterval) {

Serial.print("Feed status: ");
if (updating) {
// Serial.println("Updating");
}
if (connection_status){
if (status ==1 ) {
Serial.println("Online");
Serial.print("Listeners: ");
Serial.println(listeners_string);
}
else
Serial.println("Offline");
}
httpRequest();

}
}

// this method makes a HTTP connection to the server:
void httpRequest() {
// close any connection before send a new request.
// This will free the socket on the WiFi shield
client.stop();

// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP POST request - A GET will not return the needed information, must be a POST
client.println("POST /status/feed/10746 HTTP/1.1");
client.println("Host: broadcastify.com");
client.println("User-Agent: arduino-ethernet");
client.println("Connection: close");
client.println();

// note the time that the connection was made:
lastConnectionTime = millis();
connection_status = 1;
status = 1;
updating = 0;
}
else {
// if you couldn't make a connection:
Serial.println("connection failed, retrying");
connection_status = 0;
updating = 1;
}
}
//

No comments:

Post a Comment