Show Posts
Pages: [1] 2 3 ... 39
1  Using Arduino / General Electronics / Cheapest PCB house? on: August 07, 2014, 04:55:02 am
Hi all. I have used iTead and OSHpark before - OSHpark seems expensive for anything bigger than a 2x2cm board, iTead are very cheap but sometimes I don't need 10 boards.

What are the other options out there?
2  Community / Exhibition / Gallery / Re: Bathroom fan control on: August 06, 2014, 10:15:37 am
nice idea and implementation. Where do you get 5v from?
3  Using Arduino / Programming Questions / Re: capsense pin assignments? on: July 28, 2014, 08:15:14 pm
Thanks for clearing that up smiley

I wonder why everyone seems to use the even number pins  smiley-confuse

Thanks again  smiley
4  Using Arduino / Programming Questions / capsense pin assignments? on: July 26, 2014, 08:50:39 pm
Hi all. I am looking at making a small array of capacitive touch switches using the capsense library.

They use pins 2,4,6 etc and I'm wondering why they omit pin 3 for example. Could another pins be used if configured correctly,  how about using analog pins?

Thanks
5  Using Arduino / Programming Questions / Re: Sketch won't exit from while statement on: June 26, 2014, 06:51:48 am
Thanks all. I have got it working now,

Many thanks to ecojack, I was not aware of that. Thank you for sharing!

One other thing I would like to do is to execute a line of code ONLY once, when the while statement becomes untrue - is there a simple way to do this?
6  Using Arduino / Programming Questions / Re: Sketch won't exit from while statement on: June 24, 2014, 08:26:07 am
I think I follow, thanks for the help.

So I'm declaring double t1 again inside the while loop and I don't need too?

Thanks again
7  Using Arduino / Programming Questions / Sketch won't exit from while statement on: June 24, 2014, 05:54:53 am
Hi all. I'm confused, I am taking a temperature reading, and when it goes about a certain value the sketch enters a while loop (while (t1 > 65),  which switches power off until it cools below the value.

The sketch enters the while loop but won't exit it - I'm confused because I can see the value dropping below the set point on serial  monitor and on the LCD whilst in the while loop but like I said, it never seems to become untrue?

Thanks in advance!

Code:
#include <LCD5110_Basic.h>
#include <math.h>

//Thermistor measurements and averaging
#define NUMSAMPLES 16 // Number of analog samples to take
float averageTemp = 0;         //place to store average reading
double convert(double RawADC)
{
  double Temp;
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
  Temp = Temp - 273.15;            // Convert Kelvin to Celcius
  return Temp;
}
#define t1Pin A3  // Input pin for the thermistor 1
float average1 = 0;                     //input1

int val = 3;

LCD5110 myGLCD(8,9,10,11,12);

extern uint8_t SmallFont[];
extern uint8_t MediumNumbers[];
extern uint8_t BigNumbers[];

int backLight = 6;
int UV = 5;


// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int enterState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

long runTime = 0;
long startMillis = 0;
int remainingB = 0;
long remaining = 0;

bool running = true;

int selectButton = 2;
int enterButton = 3;

void setup()
{
  Serial.begin(9600);
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
  pinMode(UV, OUTPUT);
  pinMode(backLight, OUTPUT);
  analogWrite(backLight, 255);

  //Buttons
  pinMode(enterButton, INPUT);
  pinMode(selectButton, INPUT);
  digitalWrite(enterButton, HIGH);
  digitalWrite(selectButton, HIGH);
}

void loop()
{

  checkButton();

  while (buttonPushCounter == 0)    //Display amount menu
  {
    runTime = 30;
    //Serial.println(runTime);
    //myGLCD.clrScr();
    myGLCD.print("Select:", LEFT, 0);
    myGLCD.print("30 seconds", CENTER, 16);
    myGLCD.print("Next     Start", CENTER, 40);
    enter ();
    checkButton();
    //delay (5000);
    getTemp();  
  }


  while (buttonPushCounter == 1)    //Display amount menu
  {
    runTime = 60;
    //Serial.println(runTime);
    //myGLCD.clrScr();
    myGLCD.print("Select:", LEFT, 0);
    myGLCD.print("60 seconds", CENTER, 16);
    myGLCD.print("Next     Start", CENTER, 40);
    enter ();
    checkButton();
    //delay (5000);
    getTemp();
  }

  while (buttonPushCounter == 2)    //Display amount menu
  {
    runTime = 120;

    //myGLCD.clrScr();
    myGLCD.print("Select:", LEFT, 0);
    myGLCD.print("120 seconds", CENTER, 16);
    myGLCD.print("Next     Start", CENTER, 40);
    enter ();
    checkButton();
    //delay (5000);
    getTemp();
  }

  while (buttonPushCounter == 3)    //Display amount menu
  {
    runTime = 180;

    //myGLCD.clrScr();
    myGLCD.print("Select:", LEFT, 0);
    myGLCD.print("180 seconds", CENTER, 16);
    myGLCD.print("Next     Start", CENTER, 40);
    enter ();
    checkButton();
    //delay (5000);
    getTemp();
  }

} //end of loop


void getTemp()
{
  // Thermistor measurement and averaging
  uint8_t i;
  for (i=0; i< NUMSAMPLES; i++)            
  {
    val = analogRead(3);
    //Serial.println(val);
    val = map(val, 0, 1023, 1023, 0);

    average1 += val;
    delay(10);
  }
  average1 /= NUMSAMPLES;


  double t1 = convert(average1);
Serial.println(t1);

  myGLCD.printNumI(t1, 60, 0);
  myGLCD.print("~c", 72, 0);


  while (t1 > 65)
  {

    analogWrite(UV, 0);
    // Thermistor measurement and averaging
    uint8_t i;
    for (i=0; i< NUMSAMPLES; i++)            
    {
      val = analogRead(3);
      //Serial.println(val);
      val = map(val, 0, 1023, 1023, 0);

      average1 += val;
      delay(10);
    }
    average1 /= NUMSAMPLES;


    double t1 = convert(average1);
    Serial.println(t1);
    myGLCD.clrScr();
    myGLCD.printNumI(t1, 60, 0);
    myGLCD.print("~c", 72, 0);
    myGLCD.print("Over Temp!!", CENTER, 16);
  }  
}



void enter ()
{
  enterState = digitalRead(enterButton);
  //Serial.println(enterState);
  if (enterState == 0)
  {
    running = true;
    delay(500);
    myGLCD.clrScr();

    startMillis = millis();
    if (running == true)
    {

      runTime = (runTime * 1000);
      Serial.println(runTime);
      remaining = ((startMillis + runTime) - millis());

      //while (millis() <= (startMillis + runTime))
      while (remaining > 0)
      {
        myGLCD.clrRow(2);
        myGLCD.clrRow(3);
        myGLCD.clrRow(4);

        analogWrite(UV, 255);
        remaining = ((startMillis + runTime) - millis());
        //Serial.println(millis());

        myGLCD.print("Running:", LEFT, 0);
        //remainingB = remaining;
        //myGLCD.printNumI((remainingB / 1000), CENTER, 16);
        myGLCD.setFont(BigNumbers);
        myGLCD.printNumI((remaining / 1000), CENTER, 16);
        myGLCD.setFont(SmallFont);
        getTemp();
        myGLCD.print("Stop", LEFT, 40);
        checkButton();
        running = false;
        delay(50);
      }
      analogWrite(UV, 0);
      myGLCD.clrScr();
      myGLCD.invert(true);
      myGLCD.print("Finished", CENTER, 16);
      delay (3000);
      myGLCD.invert(false);
      myGLCD.clrScr();
      buttonPushCounter = 0;
    }
  }
}



void checkButton()
{
  // read the pushbutton input pin:
  buttonState = digitalRead(selectButton);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {

    running = false;
    remaining = 0;

    // if the state has changed, increment the counter
    if (buttonState == LOW) {
      //remaining = 0;

      // if the current state is HIGH then the button
      // wend from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes:  ");
      Serial.println(buttonPushCounter);
      myGLCD.clrScr(); //clear lcd in between screens
    }
    else {
      // if the current state is LOW then the button
      // wend from on to off:
      Serial.println("off");
    }
  }
  // save the current state as the last state,
  //for next time through the loop
  lastButtonState = buttonState;


  if(buttonPushCounter == 4)
    buttonPushCounter = 0;

} //end of sub routine

8  Using Arduino / LEDs and Multiplexing / Re: 74HC595 causes LED'S TO flash when arduino starts up on: June 12, 2014, 04:53:26 am
thanks Paul I will give it  go when i get some time!

Which is pin 10 on the shift regsisters? I'm using them in non-spi mode as I'm using them with a Ethernet shield.
9  Using Arduino / LEDs and Multiplexing / Re: 74HC595 causes LED'S TO flash when arduino starts up on: June 12, 2014, 04:22:17 am
thanks Paul I will give it  go when i get some time!

Which is pin 10 on the shift regsisters? I'm using them in non-spi mode as I'm using them with a Ethernet shield.
10  Using Arduino / LEDs and Multiplexing / Re: 74HC595 causes LED'S TO flash when arduino starts up on: June 10, 2014, 06:04:34 am
Hi Jimbo, I will give that a go then thanks! -all 3 shift register pins?

Thought it would be a hardware thing but if its only software that would be great
11  Using Arduino / LEDs and Multiplexing / 74HC595 causes LED'S TO flash when arduino starts up on: June 10, 2014, 05:30:47 am
Hi all,

Just a niggle with my project - when I apply power to my arduino all the leds that I'm driving (via mosfets) from a few 74HC595'S blink for a fraction of a second - is there a hardware mod that I can do to eradicate this?

thanks!
12  Community / Exhibition / Gallery / Re: Lib for manipulating cascaded 595 shift registers on: June 09, 2014, 08:51:05 am
thanks for sharing, looks very useful smiley
13  Community / Exhibition / Gallery / Re: [ASTROPHOTO] Autoguiding using an old webcam and an arduino on: June 09, 2014, 08:49:01 am
amazing! looks like epic work, have you got any images to share to show the results?
14  Community / Exhibition / Gallery / Re: TLC 5940 4x4x4 RGB LED cube on: June 03, 2014, 08:46:58 am
cool thanks for sharing
15  Topics / Science and Measurement / Re: Best logging site to use on: June 02, 2014, 06:59:53 am
Thanks for the replies. I can't find my old code. I a play over the weekend and got Xively working but not very impressed really, seems quite limited what it can do. Might have to check out Grovestreams
Pages: [1] 2 3 ... 39