Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ejgertz committed Sep 17, 2011
1 parent 373021c commit dca775f
Show file tree
Hide file tree
Showing 9 changed files with 1,273 additions and 0 deletions.
143 changes: 143 additions & 0 deletions chapter-3/4Char
@@ -0,0 +1,143 @@
/*
4Char Test
Sketch in Programming to test a scrolling 4-character display.
This example code is in the public domain.
*/

#include <SoftwareSerial.h>[a]
#define SerialIn 2
#define SerialOut 3[b]
#define 4Delay 600


SoftwareSerial mySerialPort(SerialIn, SerialOut);[c]


void setup()
{
pinMode(SerialOut, OUTPUT);
pinMode(SerialIn, INPUT);[d]


mySerialPort.begin(9600);
mySerialPort.print("v");[e]




}


void loop()
{


mySerialPort.print("xxxx")[f];
delay(4Delay);
mySerialPort.print("xxx1");
delay(4Delay);
mySerialPort.print("xx12");
delay(4Delay);
mySerialPort.print("x123");
delay(4Delay);


mySerialPort.print("1234"[g])[h];
delay(4Delay);


mySerialPort.print("2345");
delay(4Delay);


mySerialPort.print("3456");
delay(4Delay);
mySerialPort.print("4567");
delay(4Delay);
mySerialPort.print("5678");
delay(4Delay);
mySerialPort.print("6789");
delay(4Delay);
mySerialPort.print("7890");
delay(4Delay);
mySerialPort.print("8900");
delay(4Delay);
mySerialPort.print("9000");
delay(4Delay);
mySerialPort.print("0000");
delay(4Delay);


for (int i = 0; i <250; i++)
{
mySerialPort.print(0x77);
mySerialPort.print(itoa(i,););
}




mySerialPort.print("----");
delay(4Delay);
mySerialPort.print("8888");
delay(4Delay);


mySerialPort.print("----");
delay(4Delay);
mySerialPort.print("xxxx");
delay(4Delay);


mySerialPort.print("xxxH");
delay(4Delay);
mySerialPort.print("xxHE");
delay(4Delay);
mySerialPort.print("xHEL")[i];
delay(4Delay);




mySerialPort.print("HELL");
delay(4Delay);


mySerialPort.print("ELLO");
delay(4Delay);
mySerialPort.print("LLOx");
delay(4Delay);






mySerialPort.print("LOxt");
delay(4Delay);
mySerialPort.print("Lxth");
delay(4Delay);
mySerialPort.print("xthE");
delay(4Delay);
mySerialPort.print("thEr");
delay(4Delay);


mySerialPort.print("hErE");
delay(4Delay);
mySerialPort.print("ErEx");
delay(4Delay);
mySerialPort.print("rExx");
delay(4Delay);
mySerialPort.print("Exxx");
delay(4Delay);
mySerialPort.print("xxxx");[j]
delay(4Delay);


delay(4Delay);
delay(4Delay);
delay(4Delay);


}
238 changes: 238 additions & 0 deletions chapter-4/EMFDetector
@@ -0,0 +1,238 @@
// Arduino Electromagnetic Interference Detector
// Code modified by Patrick Di Justo, based on
// Aaron ALAI EMF Detector April 22nd 2009 VERSION 1.0
// aaronalai1@gmail.com


int inPin = 5;
int val = 0;


void setup()
{
// So simple there's nothing to set up!
}

void loop()
{

val = analogRead(inPin);

Serial.println(val);
val = map(val, 1, 100, 1, 2048);
tone(9,val,10);

}

If you want to get a more precise type of reading, make this simple change to the circuit at Step 6: Connect GND pin on the 4char to Arduino GND, and RX pin to Arduino digital pin 8


And load the following code:
// Arduino Electromagnetic interference detector
// Code modified by PAtrick Di Justo, based on
// Aaron ALAI EMF Detector April 22nd 2009 VERSION 1.0
// aaronalai1@gmail.com


#include <SoftwareSerial.h>
#define SerialIn 2
#define SerialOut 7


#define wDelay 900


byte thou=0;
byte hund=0;
byte tens=0;
byte ones=0;


int inPin = 5;
int val = 0;

SoftwareSerial mySerialPort(SerialIn, SerialOut);


void setup()
{


pinMode(SerialOut, OUTPUT);
pinMode(SerialIn, INPUT);


mySerialPort.begin(19200);
mySerialPort.print("vv");




mySerialPort.print("xxxx");
delay(wDelay);
mySerialPort.print("----");
delay(wDelay);
mySerialPort.print("8888");
delay(wDelay);
mySerialPort.print("xxxx");
delay(wDelay);




Serial.begin(9600);

}


void loop()
{

val = analogRead(inPin);

Serial.println(val);
dispData(val);
val = map(val, 1, 100, 1, 2048);
tone(9,val,10);

}




void dispData(int i)
{


char c = ' ';

ones=0;
tens=0;
hund=0;
thou=0;



if((i<-999) || (i>9999))
{
mySerialPort.print("ERRx");
return;
}


mySerialPort.print("w");

int sign = i;
i = abs(i);

ones = i%10;
if(i>=10) tens = ((i%100)-ones)/10;
if(i>=100) hund = ((i%1000)-(tens*10)-ones)/100;
if(i>=1000) thou = ((i%10000)-(hund*100)-(tens*10)-ones)/1000;




if (thou>0)
{
mySerialPort.print(thou);
mySerialPort.print(hund);
mySerialPort.print(tens);
mySerialPort.print(ones);
return;
}


if ((hund>0)&& (sign<0))
{
mySerialPort.print("-");
mySerialPort.print(hund);
mySerialPort.print(tens);
mySerialPort.print(ones);
Serial.print((int)hund);
Serial.print((int)tens);
Serial.print((int)ones);
Serial.print(c);
return;
}



if (hund>0)
{
mySerialPort.print(hund);
mySerialPort.print(tens);
mySerialPort.print(ones);
mySerialPort.print(c);
Serial.print((int)hund);
Serial.print((int)tens);
Serial.print((int)ones);
Serial.print(c);
return;
}


if ((tens>0) && (sign<0))
{
mySerialPort.print("-");
mySerialPort.print(tens);
mySerialPort.print(ones);
mySerialPort.print(c);
Serial.print("-");
Serial.print((int)tens);
Serial.print((int)ones);
Serial.print(c);




return;
}


if (tens>0)
{
mySerialPort.print(tens);
mySerialPort.print(ones);
mySerialPort.print("x");
mySerialPort.print(c);
Serial.print((int)tens);
Serial.print((int)ones);
Serial.print("x");
Serial.print(c);




return;
}


if((ones>0) && (sign<0))
{
mySerialPort.print("-");
mySerialPort.print(ones);
mySerialPort.print("x");
mySerialPort.print(c);
Serial.print("-");
Serial.print((int)ones);
Serial.print("x");
Serial.print(c);
return;
}



if(ones>0)
{
mySerialPort.print("x");
mySerialPort.print(ones);
mySerialPort.print("x");
mySerialPort.print(c);
Serial.print("x");
Serial.print((int)ones);
Serial.print("x");
Serial.print(c);
return;
}
}

0 comments on commit dca775f

Please sign in to comment.