I've got a few projects in mind, but nothing's settled yet - have some cleaning up around my house to do first.
My roof is fixed - it no longer leaks. YAY!!
& i finally upgraded the RAM in my computer (to 2.5GB - not impressive but a long way better than it used to be) - no more tedious wai-i-ting-ng for screens to change etc..
Even my head-space is improving - not feeling quite so intimidated by the 'things-to-do' list.
And i phoned my former instructor Peter Brook today - should pop in to see him next week.
.
09 March 2012
19 September 2011
Dunedin Makerspace -- a welcome discovery
Found, much to my relief, the Dunedin Makerspace.
i'm probably not going back to Polytech next year, so i need somewhere else to go..
They do, among other things, Linux (mostly Ubuntu), & they have a couple of 3D printers!
These are fascinating creatures, & i'm really interested in their possibilities
.
Labels:
3D Printers,
Arduino,
hardware,
Linux,
Makerspace
22 July 2010
24 June 2010
When all else fails, follow the instructions..
My Minor Project might've gone a little better if i'd stuck to Lewis Loflin's original instructions.
It wouldn't be the first time. Back in the day, when i had (by chance) the use of my (at the time) boss's workshop, i decided to give my sister's car a bit of a clean-up.
More..
And it was a horrible, horrible car!
It wouldn't be the first time. Back in the day, when i had (by chance) the use of my (at the time) boss's workshop, i decided to give my sister's car a bit of a clean-up.
More..
And it was a horrible, horrible car!
21 June 2010
The Final Week - schlepping around.. Soccer World Cup, Bye-bye Carisbrook..
I think "schlepping" is Yiddish - a linguistic cross between Hebrew & German.
At a guess, i'd say the name is a 'corruption' of 'Judisch' or something similar (I know a few words of German, just..).
Anyway, i think it's a wonderfully expressive word - i like it, so i use it; means (AFAIK) what we might call 'traipsing around', poking into this & that (i Hope that's what it means!)..
.. More..
Major Project: Dual Sensors with Multiple Warnings - pics & video
Here are some pics of my Arduino-based dual-sensor monitoring device.
From the top:
*Below lower set-limit warning (flashing blue LED)
*Approaching set-limits warning
(flashing green LED)
*Above upper set-limit warning
(flashing red LED)
*Within set-limits - no warnings
And here's a video of the Monitor in action..
Labels:
Arduino,
Data-logging,
EEPROM,
photocell,
PROJECTS,
sensors,
thermistor,
video
Minor Project Revisited - a Report on failure
The Fritzing breadboard diagram differs slightly from my original.
I wondered why the EEPROM kept churning out readings regardless of whether or not the button switch was pushed - but i'd had this quick-&-dirty idea for having a LED come on when it was pushed; the on-board LED actually, which (Of Course!!) connects digital-pin 13 to Ground through the LED itself & its dropping resistor - Duh!!
Its voltage level's always going to be sagging towards Ground i.e. 0, never maintaining the level 1 needed to stop it from spitting out its data!
Connecting the button to digital pin 12 (as in Lewis Loflin's original!) fixed that problem.
Another difference is in the addressing.
My original breadboard had 2 24LC08 external EEPROMs effectively connected to the same address - writing to them may not have been a problem but reading would certainly have produced a clash (& a crash, most likely).
I2C chips have addresses of the form B1010ijk, where i,j,k=1 or 0, & each chip on a common two-wire interface requires a unique address for that interface, e.g. B1010000, B1010001, etc. The Breadboard above shows the 2 24LC08s set with 2 different addresses (achieved using pins A0, A1, A2) - see diagram.
More seriously, i couldn't get the program to produce a meaningful output on the Serial Monitor. The peculiar symbols that appeared do not appear in the ASCII table, & i've seen them before - in (deliberately) garbled transmissions in an earlier Task. The program would try to retrieve the specified number of bytes, but they were garbled.. I suspect my electronically-grubby fingers were at fault there, & that i've killed the chips (i had a spare, & karked that one also).
So, all-in-all, not a successful result.
Major Project: Dual Sensors with Multiple Warnings - software & Serial Monitor
After a few false starts, i finally got this thing working.
It needs calibrating more accurately, but i haven't had the time to do that properly..
There's the usual warning about Blogger, as follows:
NOTE: this blogger doesn't like 'less-than' signs - it thinks they're HTML thingies..
so where you see n"10 put n 'less-than' 10,
& where you see n""10 put n 'greater-than' 10.
VERY IMPORTANT!!
In the coding below there is a
#include EEPROM.h
statement.
Around the EEPROM.h there should be 'less-than' &
'greater-than' symbols.
these don't show up in these blog postings..
..AND - they disappear anything inside them as well, so..
..don't forget them!
/*
* Project: Major_Project_DualSensors_multiWarning
* Author: Jane-Maree Howard
* Date: Sunday 20/06/2010
* Platform: Arduino 18
* Purpose: To operate two different sensors - temperature & light - & record their response at intervals, giving different warnings if either response moves outside pre-set limits. Results are sent to the Serial Monitor(SM).
* Operation:
Description: Connect one end of a CdS Photocell to 5V, the other end to Analog 0. Then connect a 10K resistor from Analog 0 to ground.
This forms the light-recording voltage-divider circuit.
Connect one end of a Thermistor to 5V, the other end to Analog 1.
Then connect a 10K resistor from Analog 1 to ground.
This forms the temperature-recording voltage-divider circuit.
Connect the common cathode of a 3-colour LED to Ground,
& the Red, Green & Blue anodes through 150-Ohm current-limiting resistors
to digital-pins 12, 11, & 10 respectively.
Also connect one end of a buzzer to Ground,
& the other end through a 100-Ohm resistor to digital-pin 9.
These form the light-&-sound warning circuit.
Connect one end of a push-button switch to Ground,
& the other end to digital-pin 8.
Readings are all sent to EEPROM - the push-button switch controls the EEPROM-reading process.
Include: EEPROM.h library
Declare: 2 Analog pins & their respective reading variables;
5 Digital pins for monitoring & warning circuitry.
Setup(): Connect to SM; initialise Analog & Digital pins;
Loop(): the program loops through its sensor data-logging,
until the push-button switch is pressed.
The program then reads all recorded data from EEPROM
& send it to the SM
* Comments: I don't know what the thermistor & photocell ranges are, but on past results I'd say more than 0-255. Rather than mess about with Hi-Lo bytes, better put in the Mapping Function
*/
#include EEPROM.h // needed for using EEPROM
byte photocellPin = 0; // the photocell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from photocell voltage-divider
byte thermistorPin = 1; // the thermistor and 10K pulldown are connected to a1 int thermistorReading; // the analog reading from thermistor voltage-divider
int eepromAddress = 0; // start at EEPROM address zero
byte boardLedPin = 13; // on-board LED blinks when any reading is taken
byte redLedPin = 12; // RED LED connected to digital pin 12
byte grnLedPin = 11; // GREEN LED connected to digital pin 11
byte bluLedPin = 10; // BLUE LED connected to digital pin 10
byte buzzPin = 9; // buzzer pin
byte buttonPin = 8; // digital pin for switch connected to ground.
void setup()
{
Serial.begin(9600); // connect to SM
/* initialise the Analog recording pins as inputs */
pinMode(photocellPin,INPUT); // photocell pin
pinMode(thermistorPin,INPUT); // thermistor pin
/* initialise the Digital warning pins as outputs */
pinMode(boardLedPin, OUTPUT); // on-board LED monitors readings pinMode(redLedPin, OUTPUT); // Red LED
pinMode(grnLedPin, OUTPUT); // Green LED
pinMode(bluLedPin, OUTPUT); // Blue LED
pinMode(buzzPin, OUTPUT); // buzzer
/* initialise the push-button pin as an input & set HIGH */
pinMode(buttonPin, INPUT); // push-button pin
digitalWrite(buttonPin, HIGH); // turn on internal pull up
/* turn off all LEDs & buzzer */
digitalWrite(boardLedPin, LOW); // turn off on-board LED digitalWrite(redLedPin, LOW); // turn off Red LED
digitalWrite(grnLedPin, LOW); // turn off Green LED
digitalWrite(bluLedPin, LOW); // turn off bluLedPin
digitalWrite(buzzPin, LOW); // turn off buzzer
}//end setup()
void loop()
{
// take readings until button pushed
while (digitalRead(buttonPin) == 1)
{
// read value on thermistor pin i.e. analog 1
thermistorReading = analogRead(thermistorPin); EEPROM.write(eepromAddress,map(thermistorReading, 0, 1023, 0, 255));
eepromAddress++;
digitalWrite(boardLedPin, HIGH);
delay(150);
readingWarning(map(thermistorReading, 0, 1023, 0, 255)); digitalWrite(boardLedPin, LOW); delay(350); // about half-a-second between readings
// read value on photocell pin i.e. analog 0
photocellReading = analogRead(photocellPin); EEPROM.write(eepromAddress,map(photocellReading, 0, 1023, 0, 255));
eepromAddress++;
digitalWrite(boardLedPin, HIGH);
readingWarning(map(photocellReading, 0, 1023, 0, 255));
delay(150);
digitalWrite(boardLedPin, LOW);
delay(2500); // about 3 seconds before next readings
if (eepromAddress == 100)
eepromAddress = 0;
}//while()
Serial.println();
Serial.println("\tTemperature\tLight Level");
eepromAddress = 0;
while ( eepromAddress " 100)
{
Serial.print("\t\t");
Serial.print(int(EEPROM.read(eepromAddress))); //print temperature
eepromAddress++ ;
Serial.print("\t\t");
Serial.println(int(EEPROM.read(eepromAddress))); //print light level
eepromAddress++ ;
}//while()
}//end loop()
/* function copes with readings outside pre-set limits */
void readingWarning(int aReading)
{
if (aReading ""= 190)
{
blinkLEDnoise(grnLedPin,1800);
}//if()
if (aReading ""= 200)
{
blinkLEDnoise(redLedPin,2400);
}//if()
if (aReading "= 180)
{
blinkLEDnoise(grnLedPin,1200);
}//if()
if (aReading "= 170)
{ blinkLEDnoise(bluLedPin,600);
}//if()
}//end readingWarning()
/* function blinks LED & sounds buzzer */
void blinkLEDnoise(byte ledPin, int bTone)
{
tone(buzzPin,bTone,250);
for (byte n=0; n"10; n++)
{
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(50); }//for(n++)
}//end blinkLEDnoise()
It needs calibrating more accurately, but i haven't had the time to do that properly..
There's the usual warning about Blogger, as follows:
NOTE: this blogger doesn't like 'less-than' signs - it thinks they're HTML thingies..
so where you see n"10 put n 'less-than' 10,
& where you see n""10 put n 'greater-than' 10.
VERY IMPORTANT!!
In the coding below there is a
#include EEPROM.h
statement.
Around the EEPROM.h there should be 'less-than' &
'greater-than' symbols.
these don't show up in these blog postings..
..AND - they disappear anything inside them as well, so..
..don't forget them!
/*
* Project: Major_Project_DualSensors_multiWarning
* Author: Jane-Maree Howard
* Date: Sunday 20/06/2010
* Platform: Arduino 18
* Purpose: To operate two different sensors - temperature & light - & record their response at intervals, giving different warnings if either response moves outside pre-set limits. Results are sent to the Serial Monitor(SM).
* Operation:
Description: Connect one end of a CdS Photocell to 5V, the other end to Analog 0. Then connect a 10K resistor from Analog 0 to ground.
This forms the light-recording voltage-divider circuit.
Connect one end of a Thermistor to 5V, the other end to Analog 1.
Then connect a 10K resistor from Analog 1 to ground.
This forms the temperature-recording voltage-divider circuit.
Connect the common cathode of a 3-colour LED to Ground,
& the Red, Green & Blue anodes through 150-Ohm current-limiting resistors
to digital-pins 12, 11, & 10 respectively.
Also connect one end of a buzzer to Ground,
& the other end through a 100-Ohm resistor to digital-pin 9.
These form the light-&-sound warning circuit.
Connect one end of a push-button switch to Ground,
& the other end to digital-pin 8.
Readings are all sent to EEPROM - the push-button switch controls the EEPROM-reading process.
Include: EEPROM.h
Declare: 2 Analog pins & their respective reading variables;
5 Digital pins for monitoring & warning circuitry.
Setup(): Connect to SM; initialise Analog & Digital pins;
Loop(): the program loops through its sensor data-logging,
until the push-button switch is pressed.
The program then reads all recorded data from EEPROM
& send it to the SM
* Comments: I don't know what the thermistor & photocell ranges are, but on past results I'd say more than 0-255. Rather than mess about with Hi-Lo bytes, better put in the Mapping Function
*/
#include EEPROM.h // needed for using EEPROM
byte photocellPin = 0; // the photocell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from photocell voltage-divider
byte thermistorPin = 1; // the thermistor and 10K pulldown are connected to a1 int thermistorReading; // the analog reading from thermistor voltage-divider
int eepromAddress = 0; // start at EEPROM address zero
byte boardLedPin = 13; // on-board LED blinks when any reading is taken
byte redLedPin = 12; // RED LED connected to digital pin 12
byte grnLedPin = 11; // GREEN LED connected to digital pin 11
byte bluLedPin = 10; // BLUE LED connected to digital pin 10
byte buzzPin = 9; // buzzer pin
byte buttonPin = 8; // digital pin for switch connected to ground.
void setup()
{
Serial.begin(9600); // connect to SM
/* initialise the Analog recording pins as inputs */
pinMode(photocellPin,INPUT); // photocell pin
pinMode(thermistorPin,INPUT); // thermistor pin
/* initialise the Digital warning pins as outputs */
pinMode(boardLedPin, OUTPUT); // on-board LED monitors readings pinMode(redLedPin, OUTPUT); // Red LED
pinMode(grnLedPin, OUTPUT); // Green LED
pinMode(bluLedPin, OUTPUT); // Blue LED
pinMode(buzzPin, OUTPUT); // buzzer
/* initialise the push-button pin as an input & set HIGH */
pinMode(buttonPin, INPUT); // push-button pin
digitalWrite(buttonPin, HIGH); // turn on internal pull up
/* turn off all LEDs & buzzer */
digitalWrite(boardLedPin, LOW); // turn off on-board LED digitalWrite(redLedPin, LOW); // turn off Red LED
digitalWrite(grnLedPin, LOW); // turn off Green LED
digitalWrite(bluLedPin, LOW); // turn off bluLedPin
digitalWrite(buzzPin, LOW); // turn off buzzer
}//end setup()
void loop()
{
// take readings until button pushed
while (digitalRead(buttonPin) == 1)
{
// read value on thermistor pin i.e. analog 1
thermistorReading = analogRead(thermistorPin); EEPROM.write(eepromAddress,map(thermistorReading, 0, 1023, 0, 255));
eepromAddress++;
digitalWrite(boardLedPin, HIGH);
delay(150);
readingWarning(map(thermistorReading, 0, 1023, 0, 255)); digitalWrite(boardLedPin, LOW); delay(350); // about half-a-second between readings
// read value on photocell pin i.e. analog 0
photocellReading = analogRead(photocellPin); EEPROM.write(eepromAddress,map(photocellReading, 0, 1023, 0, 255));
eepromAddress++;
digitalWrite(boardLedPin, HIGH);
readingWarning(map(photocellReading, 0, 1023, 0, 255));
delay(150);
digitalWrite(boardLedPin, LOW);
delay(2500); // about 3 seconds before next readings
if (eepromAddress == 100)
eepromAddress = 0;
}//while()
Serial.println();
Serial.println("\tTemperature\tLight Level");
eepromAddress = 0;
while ( eepromAddress " 100)
{
Serial.print("\t\t");
Serial.print(int(EEPROM.read(eepromAddress))); //print temperature
eepromAddress++ ;
Serial.print("\t\t");
Serial.println(int(EEPROM.read(eepromAddress))); //print light level
eepromAddress++ ;
}//while()
}//end loop()
/* function copes with readings outside pre-set limits */
void readingWarning(int aReading)
{
if (aReading ""= 190)
{
blinkLEDnoise(grnLedPin,1800);
}//if()
if (aReading ""= 200)
{
blinkLEDnoise(redLedPin,2400);
}//if()
if (aReading "= 180)
{
blinkLEDnoise(grnLedPin,1200);
}//if()
if (aReading "= 170)
{ blinkLEDnoise(bluLedPin,600);
}//if()
}//end readingWarning()
/* function blinks LED & sounds buzzer */
void blinkLEDnoise(byte ledPin, int bTone)
{
tone(buzzPin,bTone,250);
for (byte n=0; n"10; n++)
{
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(50); }//for(n++)
}//end blinkLEDnoise()
Labels:
Arduino,
Data-logging,
EEPROM,
photocell,
PROJECTS,
sensors,
Serial Monitor,
software,
thermistor
Task 59 - 24-hour Data-logging to EEPROM: software
/* I haven't had a chance to do the 24-hour data-logging,
but i have tested this software over a limited number
of values, & it does work as intended.. */
/*
* Project: My_24-hour_DataLogging_Thermistor_task_58
* Author: Jane-Maree Howard
* Date: Thursday 17/06/2010
* Platform: Arduino 18
* Purpose: To data-log successive readings from a thermistor
over a 24-hour period, saving the readings into EEPROM.
A hardware refinement will be needed to enable the results
to be outputted on demand.
* Operation: The average resistance of the thermistor is about 10 kOhms,
so it & the 10k resistor form a voltage divider, whose
junction is inputted to Analog 0.
* Description:
* Connect one end of the thermistor to 5V, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
this is similar to the photocell Task, but the software is
quite different.
Connect one end of a pushbutton switch to Digital pin 12, & the
other end to Ground. Declare Pin 12 as an INPUT, & initialise
it as HIGH (see Comment 3).
* Comment: (1) One thing I FORGOT was scaling; I don't know what the thermistor
range is but on past results I'd say more than 0-255.
Rather than mess about with Hi-Lo bytes,
I'd better put in the Mapping Function
(2) The EEPROM capacity of the Arduino Duemilanove is 1 kiloByte,
i.e. 1048 Bytes so 1048 is the maximum number of values that
can be stored in the Dunemilanove's EEPROM, if each value is
(as it will be scaled to be) 1 Byte.
24 hours is 1440 minutes so a sampling every 2 minutes will
produce 720 sample values, easily accomodated by the EEPROM.
(3) The push-button function in my (dead) Minor Project will come
in useful for delaying the output of results until data-logging
is complete. I might put some kind of cap over it to stop any
accidental contact being made..
NOTE: this blogger doesn't like 'less-than' signs - it thinks they're HTML thingies..
so where you see n"10 put n 'less-than' 10,
& where you see n""10 put n 'greater-than' 10.
VERY IMPORTANT!!
In the coding below there is a
#include EEPROM.h
statement.
Around the EEPROM.h there should be 'less-than' &
'greater-than' symbols.
these don't show up in these blog postings..
..AND - they disappear anything inside them as well, so..
..don't forget them!
*/
#include EEPROM.h // needed for using EEPROM
byte switchPin = 12; // the push-button switch
byte thermistorPin = 0; // the thermistor and 10K pulldown are connected to a0
int thermistorReading; // temporarilly holds unscaled thermistor readings
int readCount = 720; // this counts the readings over the 24-hour period..
int minimValue = 255; // the lowest of all the values recorded
int maximValue = 0; // the highest of all the values recorded
float meanValue; // the average (Mean) of all the values recorded
/* Everything is done here in the Setup() because we don't want to loop */
void setup(void)
{
pinMode(switchPin, INPUT); // records any input from the switch
/* set the switch-pin HIGH, so it can wait for any contact with Ground */
digitalWrite(switchPin, HIGH);
// We'll send debugging information via the Serial monitor
Serial.begin(9600); // baud rate 9600 should be set on the SM
Serial.println(); // skip a line to start with
/* First read the 10 values into mySamples[] .. */
for (byte n=0; n"readCount; n++)
{
// read value on thermistor pin i.e. analog 0
thermistorReading = analogRead(thermistorPin);
// now we have to map 0-1023 to 0-255,
// since we want to store the values as bytes, in EEPROM
EEPROM.write(n, map(thermistorReading, 0, 1023, 0, 255));
// delay 2 minutes (120 000 milli-seconds) CHECK THAT YOU CAN DO THIS!!
delay(120000);
}//for(n)
}//end setup()
void loop(void)
{
/* At this point, nothing else should happen once data-logging is
complete, until.. */
while (digitalRead(switchPin) == 1)
{ } /* hang about & do nothing until..
..the switch closes, & the pin's value dips towards
Ground i.e. switchPin == 0!
Now the program can leave the empty while-loop and start
outputting the results..
..printing values from EEPROM to the SM.. */
fromEEPROM(readCount); //maybe not
/* .. printing the minimum value to the SM.. */
Serial.print("Minimum reading = ");
Serial.println(smallestFromEEPROM(minimValue, readCount));
/* .. printing the maximum value to the SM.. */
Serial.print("Maximum reading = ");
Serial.println(biggestFromEEPROM(maximValue, readCount));
/* ..& the average (Mean) */
Serial.print("Average reading = ");
Serial.println(averageFromEEPROM(meanValue, readCount));
Serial.println();
}//end loop()
/* WE'RE NOT GOING TO OUTPUT ALL 720 VALUES FROM THE EEPROM - NO MA'AM!! */
/* Reads a given number of values from EEPROM
& prints them to the Serial Monitor
*/
void fromEEPROM(byte rCount)
{
for (byte n=0; n"rCount; n++)
{
// print the analog reading to the SM
Serial.print("Analog reading = ");
Serial.println(int(EEPROM.read(n)));
// delay 5 milli-seconds for EEPROM.read lag
delay(5);
}//for()
}//fromEEPROM()
/* Reads a given number of values from EEPROM,
determines the minimum value, & returns it.
*/
int smallestFromEEPROM(int minVal, byte rCount)
{
int temp;
for (byte n=0; n"rCount; n++)
{
temp = int(EEPROM.read(n));
// delay 5 milli-seconds for EEPROM.read lag
delay(5);
if (temp " minVal)
{
minVal = temp;
}//if()
}//for()
return minVal;
}//smallestFromEEPROM()
/* Reads a given number of values from EEPROM,
determines the maximum value, & returns it. */
int biggestFromEEPROM(int maxVal, int rCount)
{
int temp;
for (int n=0; n"rCount; n++)
{
temp = int(EEPROM.read(n));
// delay 5 milli-seconds for EEPROM.read lag
delay(5);
if (temp "" maxVal)
{
maxVal = temp;
}//if()
}//for()
return maxVal;
}//biggestFromEEPROM()
/* Reads a given number of values from EEPROM,
determines the Mean value, & returns it. */
float averageFromEEPROM(float meanVal, int rCount)
{
int temp = 0;
for (int n=0; n"rCount; n++)
{
//sum the EEPROM values &..
temp = int(EEPROM.read(n));
// ..delay 5 milli-seconds for EEPROM.read lag..
delay(5);
}//for()
//..& return the Mean value
return meanVal = temp/rCount;
}//averageFromEEPROM()
but i have tested this software over a limited number
of values, & it does work as intended.. */
/*
* Project: My_24-hour_DataLogging_Thermistor_task_58
* Author: Jane-Maree Howard
* Date: Thursday 17/06/2010
* Platform: Arduino 18
* Purpose: To data-log successive readings from a thermistor
over a 24-hour period, saving the readings into EEPROM.
A hardware refinement will be needed to enable the results
to be outputted on demand.
* Operation: The average resistance of the thermistor is about 10 kOhms,
so it & the 10k resistor form a voltage divider, whose
junction is inputted to Analog 0.
* Description:
* Connect one end of the thermistor to 5V, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
this is similar to the photocell Task, but the software is
quite different.
Connect one end of a pushbutton switch to Digital pin 12, & the
other end to Ground. Declare Pin 12 as an INPUT, & initialise
it as HIGH (see Comment 3).
* Comment: (1) One thing I FORGOT was scaling; I don't know what the thermistor
range is but on past results I'd say more than 0-255.
Rather than mess about with Hi-Lo bytes,
I'd better put in the Mapping Function
(2) The EEPROM capacity of the Arduino Duemilanove is 1 kiloByte,
i.e. 1048 Bytes so 1048 is the maximum number of values that
can be stored in the Dunemilanove's EEPROM, if each value is
(as it will be scaled to be) 1 Byte.
24 hours is 1440 minutes so a sampling every 2 minutes will
produce 720 sample values, easily accomodated by the EEPROM.
(3) The push-button function in my (dead) Minor Project will come
in useful for delaying the output of results until data-logging
is complete. I might put some kind of cap over it to stop any
accidental contact being made..
NOTE: this blogger doesn't like 'less-than' signs - it thinks they're HTML thingies..
so where you see n"10 put n 'less-than' 10,
& where you see n""10 put n 'greater-than' 10.
VERY IMPORTANT!!
In the coding below there is a
#include EEPROM.h
statement.
Around the EEPROM.h there should be 'less-than' &
'greater-than' symbols.
these don't show up in these blog postings..
..AND - they disappear anything inside them as well, so..
..don't forget them!
*/
#include EEPROM.h // needed for using EEPROM
byte switchPin = 12; // the push-button switch
byte thermistorPin = 0; // the thermistor and 10K pulldown are connected to a0
int thermistorReading; // temporarilly holds unscaled thermistor readings
int readCount = 720; // this counts the readings over the 24-hour period..
int minimValue = 255; // the lowest of all the values recorded
int maximValue = 0; // the highest of all the values recorded
float meanValue; // the average (Mean) of all the values recorded
/* Everything is done here in the Setup() because we don't want to loop */
void setup(void)
{
pinMode(switchPin, INPUT); // records any input from the switch
/* set the switch-pin HIGH, so it can wait for any contact with Ground */
digitalWrite(switchPin, HIGH);
// We'll send debugging information via the Serial monitor
Serial.begin(9600); // baud rate 9600 should be set on the SM
Serial.println(); // skip a line to start with
/* First read the 10 values into mySamples[] .. */
for (byte n=0; n"readCount; n++)
{
// read value on thermistor pin i.e. analog 0
thermistorReading = analogRead(thermistorPin);
// now we have to map 0-1023 to 0-255,
// since we want to store the values as bytes, in EEPROM
EEPROM.write(n, map(thermistorReading, 0, 1023, 0, 255));
// delay 2 minutes (120 000 milli-seconds) CHECK THAT YOU CAN DO THIS!!
delay(120000);
}//for(n)
}//end setup()
void loop(void)
{
/* At this point, nothing else should happen once data-logging is
complete, until.. */
while (digitalRead(switchPin) == 1)
{ } /* hang about & do nothing until..
..the switch closes, & the pin's value dips towards
Ground i.e. switchPin == 0!
Now the program can leave the empty while-loop and start
outputting the results..
..printing values from EEPROM to the SM.. */
fromEEPROM(readCount); //maybe not
/* .. printing the minimum value to the SM.. */
Serial.print("Minimum reading = ");
Serial.println(smallestFromEEPROM(minimValue, readCount));
/* .. printing the maximum value to the SM.. */
Serial.print("Maximum reading = ");
Serial.println(biggestFromEEPROM(maximValue, readCount));
/* ..& the average (Mean) */
Serial.print("Average reading = ");
Serial.println(averageFromEEPROM(meanValue, readCount));
Serial.println();
}//end loop()
/* WE'RE NOT GOING TO OUTPUT ALL 720 VALUES FROM THE EEPROM - NO MA'AM!! */
/* Reads a given number of values from EEPROM
& prints them to the Serial Monitor
*/
void fromEEPROM(byte rCount)
{
for (byte n=0; n"rCount; n++)
{
// print the analog reading to the SM
Serial.print("Analog reading = ");
Serial.println(int(EEPROM.read(n)));
// delay 5 milli-seconds for EEPROM.read lag
delay(5);
}//for()
}//fromEEPROM()
/* Reads a given number of values from EEPROM,
determines the minimum value, & returns it.
*/
int smallestFromEEPROM(int minVal, byte rCount)
{
int temp;
for (byte n=0; n"rCount; n++)
{
temp = int(EEPROM.read(n));
// delay 5 milli-seconds for EEPROM.read lag
delay(5);
if (temp " minVal)
{
minVal = temp;
}//if()
}//for()
return minVal;
}//smallestFromEEPROM()
/* Reads a given number of values from EEPROM,
determines the maximum value, & returns it. */
int biggestFromEEPROM(int maxVal, int rCount)
{
int temp;
for (int n=0; n"rCount; n++)
{
temp = int(EEPROM.read(n));
// delay 5 milli-seconds for EEPROM.read lag
delay(5);
if (temp "" maxVal)
{
maxVal = temp;
}//if()
}//for()
return maxVal;
}//biggestFromEEPROM()
/* Reads a given number of values from EEPROM,
determines the Mean value, & returns it. */
float averageFromEEPROM(float meanVal, int rCount)
{
int temp = 0;
for (int n=0; n"rCount; n++)
{
//sum the EEPROM values &..
temp = int(EEPROM.read(n));
// ..delay 5 milli-seconds for EEPROM.read lag..
delay(5);
}//for()
//..& return the Mean value
return meanVal = temp/rCount;
}//averageFromEEPROM()
Labels:
Arduino,
Data-logging,
EEPROM,
sensors,
software,
TASKS,
thermistor
Subscribe to:
Posts (Atom)