Show Posts
Pages: 1 ... 9 10 [11] 12 13
151  Using Arduino / General Electronics / Re: Logic Level Converters. on: September 01, 2013, 06:12:58 am
CD4050 at Tayda $0.24, not to bad a price.
152  Using Arduino / Audio / Re: Where should I get my "feed" on: August 27, 2013, 06:44:00 am
I would say from the direct source. Worked as a sound man for a few years and always feed the mixer to the eq then to the main amp.
153  Using Arduino / General Electronics / Re: Recommend me some stuff to add to an order... on: August 26, 2013, 08:35:04 am
Before you place your order from Tayda be sure to check their Facebook page
https://www.facebook.com/TaydaElectronics they frequently offer a 15% discount code.
I just placed an order Friday the 23rd. and it was shipped the 24th, will be here this week. Also you can request parts they don't carry on their Facebook page. Just thought I'd mention this.
154  Using Arduino / LEDs and Multiplexing / Re: Drive 1W LEDs from batteries on: August 26, 2013, 08:23:08 am
If you are thinking of using the module from DX, maybe this will better suit you.
http://dx.com/p/350-400ma-regulated-led-driver-circuit-board-for-diy-flashlight-1-2-1-5v-128084
You get 2 boards and they say 1.2v-1.5v input. Though the reviews say you get stable current at 1.5.
155  Using Arduino / Programming Questions / Re: tone() through PWM pin, voltage control on: August 23, 2013, 07:19:41 am
Could you post your whole code?
156  Using Arduino / Programming Questions / Re: tone() through PWM pin, voltage control on: August 22, 2013, 08:24:31 am
A low pass filter will only block the high frequencies, it will slightly reduce the volume but won't give you control over it.
With the toneAC library and additional programing, you could use a pot to control the volume.
157  Using Arduino / Programming Questions / Re: tone() through PWM pin, voltage control on: August 22, 2013, 07:05:33 am
Have you tried Tim's toneAC library? It allows you to change the volume from 1-10.
http://forum.arduino.cc/index.php?topic=142097.0
158  Using Arduino / Displays / Re: LCD touch : increase or decrease as per touch on: August 09, 2013, 07:15:17 am
Try a short delay after you press the screen so you have time to remove your finger before the next reading.

Quick way using delay();

Code:
while (true)
{
if (myTouch.dataAvailable())
{
myTouch.read(); // this reads the touchscreen
int x1=myTouch.getX(); // assign the x and y coordinates to variables
int y1=myTouch.getY(); //
int i;
if ((y1>=31) && (y1<=49)) {                   
if ((x1>=142) && (x1<=160)) {               
waitForIt(142, 30, 162, 54);
//This is where I'm not able to think of.......
//Increase the number
i++;
myGLCD.printNumI(i, 110, 33);
                                                delay(500); // Half second delay 

}
if ((y1>=31) && (y1<=49)) {                   
if ((x1>=162) && (x1<=179)) {                 
waitForIt(162, 31, 179, 49);
//This is where I'm not able to think of.......
//Decrease the number
i--;
myGLCD.printNumI(i, 110, 33);
                                               delay(500); // Half second delay
}
}
}
}
}

Proper way using millis()

Code:
long now; // put these before setup with other variables
long end;
while (true)
{
if (myTouch.dataAvailable())
{
myTouch.read(); // this reads the touchscreen
int x1=myTouch.getX(); // assign the x and y coordinates to variables
int y1=myTouch.getY(); //
int i;
if ((y1>=31) && (y1<=49)) {                   
if ((x1>=142) && (x1<=160)) {               
waitForIt(142, 30, 162, 54);
                                               //This is where I'm not able to think of.......
//Increase the number
i++;
                                                myGLCD.printNumI(i, 110, 33);
                                                MyDelay(); // Calls proper delay
}
if ((y1>=31) && (y1<=49)) {                   
if ((x1>=162) && (x1<=179)) {                 
waitForIt(162, 31, 179, 49);
                                                //This is where I'm not able to think of.......
//Decrease the number
i--;
                                                myGLCD.printNumI(i, 110, 33);
                                                MyDelay(); // Calls proper delay
                                         
}
}
}
}
}

void MyDelay()
{
  long  now = millis();
  long  end = now + 500; // Set delay for half a second
  while(millis() < end)
  {
// Do what you want during delay
  }
}

Even better way cleaning up the code abit and giving more space between buttons for more accurate button reading.
Also erasing previously printed number.
Code:
int i; // put these before setup with other variables
long now;
long end;
while (true)
  {
    if (myTouch.dataAvailable())
    {
      myTouch.read(); // this reads the touchscreen
      int x1=myTouch.getX(); // assign the x and y coordinates to variables
      int y1=myTouch.getY(); //

      if ((y1>=31) && (y1<=49)) {                   
        if ((x1>=150) && (x1<=168)) { 
          waitForIt(150, 31, 168, 49);             
          //This is where I'm not able to think of.......
          //Increase the number
          i++;
          MyDelay(); // Calls proper delay
        }
        if ((x1>=178) && (x1<=195)) { 
         waitForIt(178, 31, 195, 49);               
          //This is where I'm not able to think of.......
          //Decrease the number
          i--;
          MyDelay(); // Calls proper delay

        }
      }
    }
  }
}

void MyDelay()
{
  myGLCD.print("   ", 90, 33); // Erase previous number
  long  now = millis();
  long  end = now + 500; // Set delay for half a second
  while(millis() < end)
  {
    myGLCD.printNumI(i, 90, 33); //print new number during delay
  }
}
159  Using Arduino / Programming Questions / Re: Switch Case Using Touchscreen on: July 18, 2013, 08:43:05 am
Maybe like this:
Code:
if ((p.x > 110) && (p.x < 235)) {
if ((p.y > 5) && (p.y < 95)) {
        count = count++;
        if (count == 4) {
          count = 0;
       }
        switch (count) {
          case 0:
            frq = 1000;
            break;
          case 1:
            frq = 750;
             break;
          case 2:
            frq = 500;
            break;
          case 3:
            frq = 250;
            break;
        }
           }
          
        }
      
160  Using Arduino / Audio / Re: WT5001M02-28P another mp3/wav cheap sound module on: July 15, 2013, 02:14:00 pm
Onesky, do you get any PWM noise through the amp when the amp is turned up and the module volume is low?
161  Using Arduino / Audio / Re: WT5001M02-28P another mp3/wav cheap sound module on: June 26, 2013, 11:38:29 am
You can use the while(true) in WaitForCall as if it was a loop. And anything you put above while(true) in WaitForCall will run once when WaitForCall is called from setup() or from CallDone or anywhere else you would stick it in your code. Same goes for the CallDone function. Or any other function you create AND use while(true) in it.

Going through CallDone:
This part of CallDone
Code:
digitalWrite(timeRelay, LOW);
    digitalWrite(remoteControl, LOW);
    digitalWrite(led_tR, LOW);
    digitalWrite(led_rC, LOW);
gets run once like a setup for the function.

Then this
Code:
int val = digitalRead(optocoup_pager);
  if (val == LOW) {   
    WaitForCall();
}
(and anything you add to it) is looped inside while(true) until it is broken when your if (val == LOW) is true or any other interrupt you wish happens.
Try putting your code for the hydrostat and thermostat in the WaitForCall while(true) above if (val == HIGH).
Create a function and use that.

Like this
Code:
void WaitForCall()
{
//Put any code here that you want to run ONLY when this function is called
while (true){
 int val = digitalRead(optocoup_pager);
 CheckWeather(); //Runs monitor weather function
  if (val == HIGH) {           
    digitalWrite(timeRelay, HIGH);
    digitalWrite(remoteControl, HIGH);
    digitalWrite(led_tR, HIGH);
    digitalWrite(led_rC, HIGH);
    digitalWrite(ledOn, HIGH);

    Serial.write(0x7E);
    Serial.write(0x03);
    Serial.write(0xA7);
    Serial.write(0x1F); //  volume max
    Serial.write(0x7E);
    delay(10);
    Serial.write(0x7E);
    Serial.write(0x04);
    Serial.write(0xA0); // A0 for SD card
    Serial.write((byte)0x00);
    Serial.write(0x01); // track number
    Serial.write(0x7E);
    delay(300);
    CallDone();
 }
}
}

void CallDone()
{

    //Put any code here that you want to run ONLY when this function is called
    digitalWrite(timeRelay, LOW);
    digitalWrite(remoteControl, LOW);
    digitalWrite(led_tR, LOW);
    digitalWrite(led_rC, LOW);

while(true)
{
 int val = digitalRead(optocoup_pager);
CheckWeather();// Use it here so not to lose monitoring while call is active
  if (val == LOW) {   
    WaitForCall();
}
}
}

void Checkweather()
{
//Put your weather monitoring code here
//It will run then return to the function it was called from
}
162  Using Arduino / Audio / Re: WT5001M02-28P another mp3/wav cheap sound module on: June 26, 2013, 05:28:32 am
Try this:
Code:
//Pager Circuit
const int ledOn = 13;                                          //Green led for visible on
const int timeRelay = 12;                                     //Timerelay for switching the light on and after delay off
const int led_tR = 11;                                        //See of the TimeRelais signal goes off
const int remoteControl  = 10;                                //To send a signal to a Remote Control.
const int led_rC = 9;                                         // See of the remote control is Off
const int optocoup_pager = 6;                                 //Pager with optocoupler
//const int buttinState = 0;                                  // variable for reading pushbutton status


void setup() {               
  pinMode(ledOn, OUTPUT);
  pinMode(timeRelay, OUTPUT);
  pinMode(led_tR, OUTPUT);
  pinMode(remoteControl, OUTPUT);
  pinMode(led_rC, OUTPUT);
  pinMode(optocoup_pager, INPUT);
 
  Serial.begin(9600);                                         
  Serial.write(0x7E);
  Serial.write(0x03);
  Serial.write(0xA7);
  Serial.write(0x1F); //  volume max
  Serial.write(0x7E);

  //start sound
  Serial.write(0x7E);
  Serial.write(0x04);
  Serial.write(0xA0); // A0 for SD card
  Serial.write((byte)0x00);
  Serial.write(0x02); // track number
  Serial.write(0x7E);
  delay(3000); 
  WaitForCall();
}

void loop() {
//Nothing needed here
}

void WaitForCall()
{
while (true){
 int val = digitalRead(optocoup_pager);
  if (val == HIGH) {           
    digitalWrite(timeRelay, HIGH);
    digitalWrite(remoteControl, HIGH);
    digitalWrite(led_tR, HIGH);
    digitalWrite(led_rC, HIGH);
    digitalWrite(ledOn, HIGH);

    Serial.write(0x7E);
    Serial.write(0x03);
    Serial.write(0xA7);
    Serial.write(0x1F); //  volume max
    Serial.write(0x7E);
    delay(10);
    Serial.write(0x7E);
    Serial.write(0x04);
    Serial.write(0xA0); // A0 for SD card
    Serial.write((byte)0x00);
    Serial.write(0x01); // track number
    Serial.write(0x7E);
    delay(300);
    CallDone();
 }
}
}

void CallDone()
{
    digitalWrite(timeRelay, LOW);
    digitalWrite(remoteControl, LOW);
    digitalWrite(led_tR, LOW);
    digitalWrite(led_rC, LOW);

while(true)
{
 int val = digitalRead(optocoup_pager);
  if (val == LOW) {   
    WaitForCall();
}
}
}
163  Using Arduino / Programming Questions / Re: Can the DS3231 RTC calculate the Day of Week based on the Date set? on: May 14, 2013, 10:35:45 am
From DS3231 library keyword.txt try this: getDoW.  It worked great for my DS1307 RTC, as its library has the same function. For the DS1307 it was:
Code:
switch (RTC.dow)
164  Using Arduino / Programming Questions / Re: Start (Momentary) Button, safety on: May 10, 2013, 07:07:26 am
If your power goes out and back on you want your program to be in the state it was previous to the power loss?
How about using an EEPROM check to start/stop the desired function at restart?
When your function starts it writes a 1 to EEPROM:
Code:
eeprom.write(1, 1);

Then in setup (or loop):
Code:
int PowerFaliureCheck = EEPROM.read(1); if(PowerFaliureCheck ==1){ star/stopt your function};
Write a zero to the EEPROM when your done so it starts normally.
165  Using Arduino / Audio / Re: WT5001M02-28P another mp3/wav cheap sound module on: April 30, 2013, 07:13:07 am
Thanks alot for answering.
I just downloaded the datasheet, will give it a thorough read through.
Pages: 1 ... 9 10 [11] 12 13