Show Posts
Pages: 1 2 [3] 4 5 ... 250
31  Using Arduino / Project Guidance / Re: What's a good, practical, hobbyist friendly, PID project on: September 05, 2014, 08:43:25 am
A home made sous vide system seems like a suitable application for some PID experiments, with the added benefit that once you get it working you get to eat the results!
32  Using Arduino / Programming Questions / Re: A PID example question on: September 04, 2014, 11:20:02 am
I assume that this is a learning exercise and that there's more to come later, but right now this:

Quote
I want to control the PWM duty cycle at the pin3

as others have said, doesn't need the PID at all. Replacing your loop function with this satisfies your requirement as written:

Code:
void loop()
{
  Input = analogRead(1);
  analogWrite(3,Input/4);
}

Is there some reason that you don't want the PWM to react so quickly?
33  Using Arduino / Programming Questions / Re: beginner doubt about variables on: September 02, 2014, 09:06:52 am
Could you have another go at explaining what you're trying to achieve? Not how you think you should do it - you seem to have some misconceptions about how assignment and variables work that are making it hard to grasp what you're after.
34  Using Arduino / Programming Questions / Re: Displaying Percentage on LCD on: September 01, 2014, 04:05:54 pm
Code:
  float SV1 = ((speedVar/225.0)*100.0);
35  Topics / Home Automation and Networked Objects / Re: Gardening systeme - Water control with virtual wire on: September 01, 2014, 07:44:21 am
This is a problem:
Code:
          dixaine= buf[1]*10;
          int unit = buf[2];

You are sending "03" to the receiver. That is ASCII characters 48 and  51. So your subsequent calc will ask for 531 minutes of watering. You'll need to subtract 48 from those two values before you use them.
36  Using Arduino / Programming Questions / Re: Questions about Serial for continuous data project on: September 01, 2014, 07:03:23 am
You're still relying on your data coming in one continuous stream and you're servicing the power meters one after the other which is giving opportunities for overflow. Also, if for some reason you don't get all the data for one of them, what you have is thrown away because your content variables are local. In addition, you're printing three sets of data on a single serial port at the same speed- if you're unlucky this has overflow possibilities too.

So,
  • Make the content variables global (or static)
  • Change your while loops to if statements
  • Print and clear content only when you get ETX
  • Increase the baud rate on Serial

Also of course, String objects are bad news on an Arduino. Once you get this working, change it to use C strings instead. Search the forums for many threads debating why Strings are problematic.
37  Using Arduino / Project Guidance / Re: Start/stop a Loop on: August 31, 2014, 01:00:56 pm
You're still using digitalWrite here, where you likely mean pinMode:
Code:
void setup()
{
  for(int can = 39; can < 54; can=can+2)   // selectam toate canalele impare de la 39 pana la 54
  {
    digitalWrite(can, OUTPUT);             // le setam ca output
  }
38  Using Arduino / Programming Questions / Re: ir remote and flashing leds on: August 31, 2014, 09:53:27 am
Code:
#include <IRremote.h>

int irPin = 11; //ir sensor pin
int landing = 5; //landing lights, taxi lights and logo lights
int Position = 6; //red/green/white lights on wing tips - no flash -
int antiCol = 7; //red flashing lights on top and bottom
const int strobe = 8; //tail and wingtips
int all[] = {5, 6, 7, 8}; //all lights
int strobeState = LOW;
long prevMillis = 0;
long interval = 3500; //time between flashes
bool StrobeIsFlashing=false;

IRrecv irrecv(irPin);
decode_results results;

void setup(){
  Serial.begin(9600); //starts serial monitor *for debuging*
  irrecv.enableIRIn(); //starts IR reciever
  pinMode(landing, OUTPUT);
  pinMode(Position, OUTPUT);
  pinMode(antiCol, OUTPUT);
  pinMode(strobe, OUTPUT);
}

void loop(){
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    Serial.println(decCode);
    switch (results.value){
      case 2079:
      digitalWrite(landing, 1);
      Serial.println("LANDING/TAXI/LOGO LIGHTS ENGAGED");
      break;
     
      case 31:
      digitalWrite(landing, 0);
      Serial.println("LANDING/TAXI/LOGO LIGHTS DISENGAGED");
      break;
     
      case 2108:
      digitalWrite(Position, 1);
      Serial.println("POSITION LIGHTS ENGAGED");
      break;
     
      case 60:
      digitalWrite(Position, 0);
      Serial.println("POSITION LIGHTS DISENGAGED");
      break;
     
      case 2060:
      Serial.println("STROBE ACTIVATED");
      StrobeIsFlashing=!StrobeIsFlashing;   
      break;
     
      default:
      Serial.println("WAITING");
    }
    irrecv.resume();
  }
if(StrobeIsFlashing)
  {
  FlashStrobe(); 
  }
}

void FlashStrobe()
{
unsigned long currentMillis = millis();
if(currentMillis - prevMillis > interval)
  {
  prevMillis = currentMillis;
  if (strobeState == 0)
    strobeState = 1;
  else
    strobeState = 0;
  digitalWrite(strobe, strobeState);
  }
}
Not tested. Compiles with errors because I don't have the IR lib.
39  Using Arduino / Programming Questions / Re: ir remote and flashing leds on: August 31, 2014, 07:48:36 am
You only change the state of your strobe when you receive a 2060 command from the remote, so it isn't going to flash. Move the flashing millis code out of the code controlled by this if:

Code:
  if (irrecv.decode(&results)){
i.e. move it to the very bottom of loop.

Add a boolean variable that tells you whether the strobe is supposed to be flashing. Toggle it when you receive a 2060. If the strobe should flash, run the millis code that does so.
40  Using Arduino / Motors, Mechanics, and Power / Re: Power switching - problems with transient pulses. on: August 31, 2014, 07:32:52 am
Your decoupling capacitor is a common solution to things of this sort, but as MarkT points out, separate power will solve it. -you're rather defeating the point of using relays if power is shared.
41  Using Arduino / Project Guidance / Re: Reef Tank lighting project on: August 28, 2014, 08:55:24 am
You will need to completely rewrite your code if you want to use manual override with pots. All those delays will have to go. I'd suggest working on the RTC piece and then adding the override.
42  Using Arduino / Project Guidance / Re: Start/stop a Loop on: August 27, 2014, 11:48:21 am
The way your code is laid out (indented) makes it difficult to read. The Arduino IDE has an option under the tools menu called autoformat which will take care of this.
43  Using Arduino / Project Guidance / Re: Start/stop a Loop on: August 26, 2014, 11:56:23 am
When you post new code, please post it again rather than editing what you had - it's a lot less confusing.
44  Using Arduino / Project Guidance / Re: Start/stop a Loop on: August 26, 2014, 09:28:17 am
The IDE's auto format feature would improve the layout of your code somewhat. Losing any repeated blank lines would help too. Moving the brackets for the loop function definition would leave the code looking less strange too.

Formatting aside, an offRelay function would be an obvious improvement. You could have another to do your pinmode commands too.
45  Using Arduino / Project Guidance / Re: can this GPS can work with Arduino? on: August 26, 2014, 09:05:53 am
Quote
how do I get at least 4 ? (for better position)

Code:
serial.Print(LonF,4); // assuming LonF is a float
Pages: 1 2 [3] 4 5 ... 250