Pages: [1]   Go Down
Author Topic: MultiMeter Project  (Read 2742 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
NomNomNom, ASCII Cake.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey all, little project i've been working on today. The code is pasted bellow. (Its pretty self explanitory).

(Im using an arduino UNO with this project.)

Code:
// Arduino MultiMeter. (This serves no real purpose, its just a bit of fun).
// Coded By Alex Richman.

// (I havn't commented on any of the code, but i've explained the wiring bellow.
// should you want to try it out).

// Wiring Explanation:

// LED Display:
// The LED display is simply 10 LEDs in a line. The Display(); Function
// Controls Them. So if the voltage mesured was 5000 MilliVolts It Would Light
// 5 LEDs. (Its Rounded, So 4499 is 4 LEDs, and 4500 is 5).
// The pins for the LEDs are:
// LED 1: DigitalPin 2.
// LED 2: DigitalPin 3.
// LED 3: DigitalPin 4.
// LED 4: DigitalPin 5.
// LED 5: DigitalPin 6.
// LED 6: DigitalPin 7.
// LED 7: DigitalPin 8.
// LED 8: DigitalPin 9.
// LED 9: DigitalPin 10.
// LED 10: DigitalPin 11.

// Other pins used:
// DigitalPin 12: Buzzer Power.
// DigitalPin 13: General light to show the board is on.

// AnalogPin 3: Input for continuity test.
// AnalogPin 4: Input for 6-10 volt read. (Important Note Bellow).
// AnalogPin 5: Input for 0-5 volt read.

// Notes:
// The 6-10 volt read consists of a voltage devider (I Used 2x 4.7k) so that
// a 6-10 volt input is reduced to 0-5. (So the board dosn't fry).

// The continuity tester is just a open connection from +5 to AnalogPin 3.
// (The user closes the connected with whatever they are testing).
int inByte;
int sIn;
int showByte;
int disByte;
int var;
int var1;
int var2;
int var3;
int var4;
int var5;
int var6;
int var7;
int var8;
int var9;
int var10;
int disVar;
int avgvar;
int LoadNumber = 0;
int i;
int raw = 0;         
int Vin = 5;         
float Vout = 0;       
float R1 = 10;       
float R2 = 0;       
float buffer = 0;
void setup() {
  Serial.begin(9600);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT); 
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(A3, INPUT);
  analogWrite(A5, HIGH);
  digitalWrite(13, HIGH);
}
void loop() {
  Main();
}
void Menu5() {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(A0, LOW);
    digitalWrite(A1, LOW);
  SerialClear();
  inByte = 0;
  showByte = 0;
  var = 0;
  var1 = 0;
  var2 = 0;
  var3 = 0;
  var4 = 0;
  var5 = 0;
  var6 = 0;
  var7 = 0;
  var8 = 0;
  var9 = 0;
  var10 = 0;
  disVar =0;
  avgvar = 0;
  sIn = 0;
  Serial.println("Arduino MultiMeter.");
  Serial.println("Coded By Alex Richman.");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println("Put Test Voltage + To Pins 1-5, And - To Ground.");
  Serial.println(" ");
  Serial.println("Enter A To Take A Voltage Reading.");
  Serial.println("Enter B To Take An Average Voltage Reading Over 10 Seconds.");
  Serial.println("Enter C To Take An Active Voltage Reading.");
  Serial.println("Enter M To Return To The Main Menu.");
  Load5();
}
void Load5() {
  LoadNumber = LoadNumber + 1;
  inByte = 0;
  showByte = 0;
  var = 0;
  var1 = 0;
  var2 = 0;
  var3 = 0;
  var4 = 0;
  var5 = 0;
  var6 = 0;
  var7 = 0;
  var8 = 0;
  var9 = 0;
  var10 = 0;
  disVar =0;
  sIn = 0;
  avgvar = 0;
  sIn = Serial.read();
  if (sIn == 'A') {
    Read5();
  }
  if (sIn == 'B') {
    Avg5();
  }
  if (sIn == 'C') {
    SerialClear();
    Active5();
  }
  if (sIn == 'M') {
    Main();
  }
  if (LoadNumber == 1) {
    LoadDis1();
  }
  if (LoadNumber == 2) {
    LoadDis2();
  }
  if (LoadNumber == 3) {
    LoadDis3();
  }
  if (LoadNumber > 3) {
    LoadNumber = 0;
  }
  Load5();
}
void Read5() {
  SerialClear();
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  Serial.println(" ");
  Serial.println("Enter T To Return To The Menu.");
  if (Serial.available() > 0) {
  while (Serial.read() != 'T');
  }
  SerialClear(); Menu5();
}
void SerialClear() {
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
}
« Last Edit: January 28, 2011, 11:36:18 am by Alexr2311 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
NomNomNom, ASCII Cake.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void Avg5() {
  SerialClear();
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var1 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var2 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var3 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var4 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var5 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var6 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var7 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var8 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var9 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var10 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000);
  avgvar = var1+var2+var3+var4+var5;
  avgvar = avgvar / 5;
  SerialClear();
  Serial.println("The Average Voltage Is:");
  Serial.println("MilliVolts:");
  Display();
  Serial.println(avgvar, DEC);
  var = avgvar;
  avgvar = avgvar / 1000;
  Serial.println("Volts:");
  Serial.print(avgvar, DEC);
  Serial.print(".");
  avgvar = avgvar * 1000;
  var = var - avgvar;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  Serial.println(" ");
  Serial.println("Enter T To Return To The Menu.");
  if (Serial.available() > 0) {
  while (Serial.read() != 'T');
  }
  SerialClear(); Menu5();
}
void Active5() {
  inByte = analogRead(A5);
  var = map (inByte, 0, 1023, 0, 5000);
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  Serial.println(" ");
  Serial.println("Enter T To Return To The Menu.");
  if (Serial.available() > 0) {
    inByte = Serial.read();
  }
  if (inByte == 'T') {
    Menu5();
  }
  delay(800);
  SerialClear();
  Active5();
}
void Display() {
  if (showByte == 0) {
    disByte = 0;
  }
  if (showByte > 1 && showByte < 1499) {
    disByte = 1;
  }
  if (showByte > 1500 && showByte < 2499) {
    disByte = 2;
  }
  if (showByte > 2500 && showByte < 3499) {
    disByte = 3;
  }
  if (showByte > 3500 && showByte < 4499) {
    disByte = 4;
  }
  if (showByte > 4500 && showByte < 5499) {
    disByte = 5;
  }
  if (showByte > 5500 && showByte < 6499) {
    disByte = 6;
  }
  if (showByte > 6500 && showByte < 7499) {
    disByte = 7;
  }
  if (showByte > 7500 && showByte < 8499) {
    disByte = 8;
  }
  if (showByte > 8500 && showByte < 9499) {
    disByte = 9;
  }
  if (showByte > 9500 && showByte < 10000) {
    disByte = 10;
  }
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(A0, LOW);
    digitalWrite(A1, LOW);
  if (disByte == 1) {
    digitalWrite(2, HIGH);
  }
  if (disByte == 2) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
  }
  if (disByte == 3) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  }
  if (disByte == 4) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
  }
  if (disByte == 5) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
  }
 
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
NomNomNom, ASCII Cake.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 
Code:
if (disByte == 6) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
  }
  if (disByte == 7) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
  }
  if (disByte == 8) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
  }
  if (disByte == 9) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(10, HIGH);
  }
  if (disByte == 10) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
  }
}
void Main() {
  SerialClear();
  Serial.println("Arduino MultiMeter.");
  Serial.println("Coded By Alex Richman.");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println("A: Read 0-5 Volts. Pins 1-5. (And Ground).");
  Serial.println("B: Read 6-10 Volts. Pins 6-10. (And Ground).");
  Serial.println(" ");
  Serial.println("C: Test Continuity. Pins 24-28. (And +5).");
  Serial.println("Enter Option:");
  MainLoad();
}
void MainLoad() {
  LoadNumber = LoadNumber + 1;
  sIn = 0;
  sIn = Serial.read();
  if (sIn == 'A') {
    Menu5();
  }
  if (sIn == 'B') {
    Menu10();
  }
  if (sIn == 'C') {
    Contin();
  }
  if (LoadNumber == 1) {
    LoadDis1();
  }
  if (LoadNumber == 2) {
    LoadDis2();
  }
  if (LoadNumber == 3) {
    LoadDis3();
  }
  if (LoadNumber > 3) {
    LoadNumber = 0;
  }
  MainLoad();
}
void Menu10() {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(A0, LOW);
    digitalWrite(A1, LOW);
  SerialClear();
  inByte = 0;
  showByte = 0;
  var = 0;
  var1 = 0;
  var2 = 0;
  var3 = 0;
  var4 = 0;
  var5 = 0;
  var6 = 0;
  var7 = 0;
  var8 = 0;
  var9 = 0;
  var10 = 0;
  disVar =0;
  avgvar = 0;
  sIn = 0;
  Serial.println("Arduino MultiMeter.");
  Serial.println("Coded By Alex Richman.");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println(" ");
  Serial.println("Put Test Voltage + To Pins 6-10, And - To Ground.");
  Serial.println(" ");
  Serial.println("Enter A To Take A Voltage Reading.");
  Serial.println("Enter B To Take An Average Voltage Reading Over 10 Seconds.");
  Serial.println("Enter C To Take An Active Voltage Reading.");
  Serial.println("Enter M To Return To The Main Menu.");
  Load10();
}
void Load10() {
  LoadNumber = LoadNumber + 1;
  inByte = 0;
  showByte = 0;
  var = 0;
  var1 = 0;
  var2 = 0;
  var3 = 0;
  var4 = 0;
  var5 = 0;
  var6 = 0;
  var7 = 0;
  var8 = 0;
  var9 = 0;
  var10 = 0;
  disVar =0;
  sIn = 0;
  avgvar = 0;
  sIn = Serial.read();
  if (sIn == 'A') {
    Read10();
  }
  if (sIn == 'B') {
    Avg10();
  }
  if (sIn == 'C') {
    SerialClear();
    Active10();
  }
  if (sIn == 'M') {
    Main();
  }
  if (LoadNumber == 1) {
    LoadDis1();
  }
  if (LoadNumber == 2) {
    LoadDis2();
  }
  if (LoadNumber == 3) {
    LoadDis3();
  }
  if (LoadNumber > 3) {
    LoadNumber = 0;
  }
  Load10();
}
void Read10() {
  SerialClear();
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  Serial.println(" ");
  Serial.println("Enter T To Return To The Menu.");
  if (Serial.available() > 0) {
  while (Serial.read() != 'T');
  }
  SerialClear(); Menu10();
}
void Avg10() {
  SerialClear();
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var1 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var2 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var3 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var4 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var5 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var6 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
NomNomNom, ASCII Cake.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var7 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var8 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var9 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000); Serial.println(" ");
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  var10 = showByte;
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  delay(1000);
  avgvar = var1+var2+var3+var4+var5;
  avgvar = avgvar / 5;
  SerialClear();
  Serial.println("The Average Voltage Is:");
  Serial.println("MilliVolts:");
  Display();
  Serial.println(avgvar, DEC);
  var = avgvar;
  avgvar = avgvar / 1000;
  Serial.println("Volts:");
  Serial.print(avgvar, DEC);
  Serial.print(".");
  avgvar = avgvar * 1000;
  var = var - avgvar;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  Serial.println(" ");
  Serial.println("Enter T To Return To The Menu.");
  if (Serial.available() > 0) {
  while (Serial.read() != 'T');
  }
  SerialClear(); Menu10();
}
void Active10() {
  inByte = analogRead(A4);
  var = map (inByte, 0, 1023, 0, 5000);
  var = var * 2;
  showByte = var;
  Serial.println("MilliVolts:");
  Display();
  Serial.println(showByte, DEC);
  showByte = showByte / 1000;
  Serial.println("Volts:");
  Serial.print(showByte, DEC);
  Serial.print(".");
  showByte = showByte * 1000;
  var = var - showByte;
  Serial.print(var, DEC);
  Serial.println(" ");
  Serial.println("-");
  Serial.println(" ");
  Serial.println("Enter T To Return To The Menu.");
  if (Serial.available() > 0) {
    inByte = Serial.read();
  }
  if (inByte == 'T') {
    Menu10();
  }
  delay(800);
  SerialClear();
  Active10();
}
void LoadDis1() {
  digitalWrite(2, HIGH);
  digitalWrite(11, HIGH);
  delay(150);
  digitalWrite(3, HIGH);
  digitalWrite(10, HIGH);
  delay(150);
  digitalWrite(4, HIGH);
  digitalWrite(9, HIGH);
  delay(150);
  digitalWrite(5, HIGH);
  digitalWrite(8, HIGH);
  delay(150);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  delay(150);
  digitalWrite(2, LOW);
  digitalWrite(11, LOW);
  delay(150);
  digitalWrite(3, LOW);
  digitalWrite(10, LOW);
  delay(150);
  digitalWrite(4, LOW);
  digitalWrite(9, LOW);
  delay(150);
  digitalWrite(5, LOW);
  digitalWrite(8, LOW);
  delay(150);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  delay(150);
}
void LoadDis2() {
  digitalWrite(2, HIGH);
  delay(150);
  digitalWrite(2, LOW);
  digitalWrite(3, HIGH);
  delay(150);
  digitalWrite(3, LOW);
  digitalWrite(4, HIGH);
  delay(150);
  digitalWrite(4, LOW);
  digitalWrite(5, HIGH);
  delay(150);
  digitalWrite(5, LOW);
  digitalWrite(6, HIGH);
  delay(150);
  digitalWrite(6, LOW);
  digitalWrite(7, HIGH);
  delay(150);
  digitalWrite(7, LOW);
  digitalWrite(8, HIGH);
  delay(150);
  digitalWrite(8, LOW);
  digitalWrite(9, HIGH);
  delay(150);
  digitalWrite(9, LOW);
  digitalWrite(10, HIGH);
  delay(150);
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(150);
  digitalWrite(11, LOW);
  delay(150);
}

void LoadDis3() {
  digitalWrite(11, HIGH);
  delay(150);
  digitalWrite(10, HIGH);
  delay(150);
  digitalWrite(9, HIGH);
  delay(150);
  digitalWrite(8, HIGH);
  delay(150);
  digitalWrite(7, HIGH);
  delay(150);
  digitalWrite(6, HIGH);
  delay(150);
  digitalWrite(5, HIGH);
  delay(150);
  digitalWrite(4, HIGH);
  delay(150);
  digitalWrite(3, HIGH);
  delay(150);
  digitalWrite(2, HIGH);
  delay(150);
  digitalWrite(11, LOW);
  delay(150);
  digitalWrite(10, LOW);
  delay(150);
  digitalWrite(9, LOW);
  delay(150);
  digitalWrite(8, LOW);
  delay(150);
  digitalWrite(7, LOW);
  delay(150);
  digitalWrite(6, LOW);
  delay(150);
  digitalWrite(5, LOW);
  delay(150);
  digitalWrite(4, LOW);
  delay(150);
  digitalWrite(3, LOW);
  delay(150);
  digitalWrite(2, LOW);
  delay(150);
}
void Contin() {
  analogWrite(A3, HIGH);
  SerialClear();
  Serial.println("Testing For Continuity.");
  Serial.println("Enter M To Return To The Main Menu.");
  TContin();
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  digitalWrite(3, LOW);
  digitalWrite(2, LOW);
  digitalWrite(12, LOW);
  SerialClear();
  Main();
}
void TContin() {
  inByte = digitalRead(A3);
  SerialClear();
  if (inByte == 1) {
  digitalWrite(11, HIGH);
  digitalWrite(10, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(2, HIGH);
  digitalWrite(12, HIGH);
  SerialClear();
  Serial.println("Testing For Continuity.");
  Serial.println("Enter M To Return To The Main Menu.");
  Serial.println("CLOSED.");
  } else {
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  digitalWrite(3, LOW);
  digitalWrite(2, LOW);
  digitalWrite(12, LOW);
  SerialClear();
  Serial.println("Testing For Continuity.");
  Serial.println("Enter M To Return To The Main Menu.");
  Serial.println(" ");
  Serial.println("OPEN.");
  }
  inByte = Serial.read();
  if (inByte == 'M') {
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  digitalWrite(3, LOW);
  digitalWrite(2, LOW);
  digitalWrite(12, LOW);
    SerialClear();
    Main();
  }
  delay(800);
  TContin();
}
   

I couldnt work out the forum picture embed stuff, so here's a link to a picture of my
wiring.

http://s1216.photobucket.com/albums/dd362/Alexrichman2311/?action=view&current=Image001.jpg

Cheers
Alex.

P.S Sorry for the multiple posts, couldnt fit the code in one... or two... or indeed three.

P.P.S After looking at the posts, i realise that the code isn't easy to read or self explainitory in any way. Appologies for this, but it should work if you paste it into a new scetch. (And wire it all up).
« Last Edit: January 28, 2011, 11:34:03 am by Alexr2311 » Logged

Pages: [1]   Go Up
Jump to: