Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 292
61  Using Arduino / Programming Questions / Re: Time Alarm Not Working (With NTP) on: September 14, 2014, 03:16:45 pm
  if (alarm == false)
    Alarm.alarmRepeat(19, 35, 0, MorningAlarm);
    alarm = true;
    Serial.println("alarm set");
Do you get the message printed indicating that the alarm is set when you expect it ?  I hope it is obvious that an alarm set for a time of  19:35:00 will not be triggered in the morning despite the name of the function.
62  Using Arduino / Programming Questions / Re: What is best method to multiplex many buttons with only 2 interrupts available? on: September 14, 2014, 09:55:10 am
In my first Arduino Mega project I had 4 buttons that needed to have a fast hardware interrupt
How fast are these buttons being pressed and released and what is the shortest interval between pressing 2 different buttons ?

If you triggered the check for button presses using an interrupt then polled the buttons using digitalRead() it seems to me that you may as well have just polled them anyway.

Will I miss a button press reading pin state for 6 pins sequentially?
That depends on what else you are doing in loop() and how you are doing it.  Seeing your program would help.

To read the state of multiple buttons at once in loop() you could use an analogue input and a resistor ladder to give a different value  for each button.
63  Using Arduino / Programming Questions / Re: display all characters at once in serial monitor on: September 14, 2014, 04:24:07 am
As was pointed out in your other thread you are not clearing the value from the val variable after printing so when you add more characters to it no wonder that you get odd results.
64  Using Arduino / Programming Questions / Re: Arduino UNO and interrupts (strange things) on: September 13, 2014, 02:16:58 pm
void blink1() {             

void blink2() {             
Interrupts are automatically disabled when an ISR is called.   Serial.print() depends on interrupts.
As suggested, have the ISRs simply update a variable (declared as volatile),and move the Serial.prints outside of the ISRs and have the prints controlled by the value of the variable updated by the ISR.
65  Using Arduino / Programming Questions / Re: Time Alarm Not Working (With NTP) on: September 13, 2014, 11:50:21 am
Whatever else may or may not be wrong your alarms will not work because you have not taken note of this from the TimeAlarms readme and/or the TimeAlarms examples.

Your sketch should call the Alarm.delay() function instead of the Arduino delay() function when
using the Alarms library.  The timeliness of triggers depends on sketch delays using this function.
66  Using Arduino / Programming Questions / Re: Help with code using relay shield to power on/off my arcade cabinet. on: September 13, 2014, 11:31:39 am
You could do what you want by counting button presses but to my mind it would be simpler to set a boolean variable to true or false depending on whether the cabinet was powered on or not.

Start with the variable, let's call it poweredOn, set to false.  Detect the state change of switch state from off to on then, if poweredOn is false execute the code to turn the power on and set poweredOn to true else if poweredOn is true execute the code to turn the power off and set poweredOn to false.

You have quite rightly turned on the internal pullup resistor to avoid the switch input floating but in my opinion it is more explicit if you use
pinMode(mainSwitch, INPUT_PULLUP);

Edit : Changed INPUT to INPUT_PULLUP
67  Using Arduino / Programming Questions / Re: Help with code using relay shield to power on/off my arcade cabinet. on: September 13, 2014, 01:27:12 am
  if(digitalRead(mainSwitch) == LOW)  // main button is pressed.
You are sensing that the button is currently pressed rather than when it becomes pressed.  You need to sense the change from on to off, ie the change of state not the current state.

Look at the StateChangeDetection example in the IDE to see how to do it.
68  Using Arduino / Programming Questions / Re: Can someone point me to what data(2) references in the below code? on: September 12, 2014, 12:28:45 pm
in the code snippet below (which comes from the DHT.cpp library, there are references to data(2) and data(3)
Actually there are references to data[2] and data[3] which are the third and fourth elements of an array called data.

As you have not posted the complete program it is impossible to be more precise as to the contents and use of the array.
69  Using Arduino / Programming Questions / Re: error compiling !!! servo and rf :/ on: September 12, 2014, 12:23:19 pm
70  Using Arduino / Programming Questions / Re: Problems with is statement on: September 12, 2014, 10:55:12 am
Here is the code
Wrong.  That is only some of the code. 
Please post it all.
71  Using Arduino / Programming Questions / Re: Code review request for RC car on: September 12, 2014, 04:41:12 am
You have not said what is wrong but from
on boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.
and in your program you have
#define MOTOR2_PWM   10 // EB  
analogWrite(MOTOR2_PWM, motor_speed);  

Try moving the affected PWM output to another pin.
72  Using Arduino / Programming Questions / Re: More qusetions about "functions" and how they work. on: September 12, 2014, 02:40:27 am
I think you are making more complicated that it is.
To set LED to red you code sends RGB = (255,0,0) , to set  blue you send RGB (0,0,255).
Now if you set SAME LED using BOTH codes it will PHYSICALLY mix the colors.
The software does not care if you send TWO lines of code to sane LED "output"
or ONE line of code
Color(255,0,255);  to same LED
Is sending 255, 0, 0 then 0, 0, 255 really the same as sending 255, 0, 255 ?

Surely sending 255, 0, 0 then 0, 0, 255 will leave the LED blue
73  Community / Bar Sport / Re: [RPI ?] Wiringpi, Bash, and PWM on: September 11, 2014, 02:39:14 am
Sorry. I didn't know there were multiple ways to connect a transistor
Not only that, there are multiple types of transistor.
The transistor is between the negative lead of the fan.
Between the negative lead of the fan and where ?
The center pin of the transistor is  connect to pin 18 of the pi
That pin does what exactly on the Pi ?
There is a capacitor between the fans + & - lead,
What type/value of capacitor ?
to have enough power to kick on and not draw to much from the device.
This is surely nonsense.
The fan won't kick on with 3.3v. Which is the rating I get with my multimeter from the PWM signal set at 1023. It will with direct 5v.
Do you understand that a PWM output does not provide a steady voltage ?  Rather it provides a fixed voltage that turns on and off, ie is Modulated, with a variable duty cycle depending on the Width of the Pulse
74  Using Arduino / Programming Questions / Re: Help with initial project on: September 10, 2014, 06:37:19 am
The problem is that the program runs non-stop and doesn’t do what I want
What does it do ?
How are the buttons wired Have you got any pull down resistors on the inputs to ensure that they are held at a known voltage when not pressed ?  If not, I suggest that you use
pinMode(buttonPin2, INPUT_PULLUP);
to activate the built in pullup resistors and change the wiring to take the inputs LOW when activated,  then use
if (buttonState2 == LOW)
to check the state of the input.  LOOK CAREFULLY at the code I used in the if.  Does it differ from yours besides the test being for LOW instead of HIGH ?
75  Using Arduino / Programming Questions / Re: Mosquito Anti Loitering Device on: September 10, 2014, 06:08:24 am
      if (pirState == LOW)//we have just turned on
Actually what you know is that the sensor was active when you checked 30 seconds ago.  Was it active for a fraction of a second ?  Is it still active ?  Who knows ?
Pages: 1 ... 3 4 [5] 6 7 ... 292