Recent Posts

Pages: [1] 2 3 ... 10
1
Hi,

I've been working in this code for a while and can't figure what is wrong.


I have 2 variables (temperature and humidity) and 4 LEDs.

I want GREEN to turn on when temp and humidity are good.
RED to turn on and YELLOW to blink when the temperature is too low or too high.
RED to turn on and BLUE to blink when the humidity is too low or too high.
RED to blink when both temp and humidity are wrong.

I didn't make it blink yet, first I'm trying to set up the code right.
Not sure if using if and else if is the right choice, or should I try the switch function.

I am new to programing.


Code: [Select]


#include <Adafruit_Sensor.h>
#include <DHT.h>


// pins definition
#define DHTPIN 7
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

// variables


void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);
  Serial.println("Testing shit!");
  pinMode (9 , OUTPUT); //BLUE
  pinMode (6 , OUTPUT); //YELLOW
  pinMode (12 , OUTPUT); //RED
    pinMode (10 , OUTPUT); //GREEN
 
  dht.begin();
}


void loop() {
  // put your main code here, to run repeatedly:

  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);

if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
}



  Serial.print("Humidity: ");
  Serial.print(h,0);
  Serial.print("%\t");
  Serial.print("Temperature: ");
  Serial.print(t,0);
  Serial.println("ÂșC ");
 
  delay(2000);
 
 if ((55 <= h && h <= 75) & (20 <= t & t <= 28)){
    // system messages
 Serial.println("Perfect!");
digitalWrite(10, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(6, LOW);
    digitalWrite(12, LOW);
   
     delay(100);

if ((h < 55 ) || (h > 75) & (t >= 20 ) & (t <= 28)) {

    Serial.println("Check Humidity!");
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(12, HIGH);
    delay(100);
 
 if ((h >= 55 ) & (h <= 75) & (t < 20 ) || (t > 28)){

    Serial.println("Check Temperature!");
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(12, HIGH);
    delay(100);

if ((t < 21) || (t > 28) & (h < 55) || (h > 75)) {
 
   Serial.println("Help!");
   digitalWrite(10, LOW);
   digitalWrite(9, LOW);
   digitalWrite(6, LOW);
   digitalWrite(12, HIGH);
   delay(100);

} } }   
   


2
Never mind I got the answer <here>
3
Never mind, I got it...

The problem was with my make call. I need to either specify my make file name in my make call, or call my make file "makefile". I had called it "make".

Hope this helps other lost souls...
4
Programming Questions / Re: Arduino Core Headers
Last post by DKWatson - Today at 06:25 am
BTW the file name is in the top/bottom header to the right
5
Programming Questions / Re: Arduino Core Headers
Last post by DKWatson - Today at 06:21 am
All sounds too much like work.

If you're in Adobe Reader, the bookmarks menu is laid out according to the Windows directory structure.

Typo noted.
6
When you pulled the project from GIT (did you use git, or did you copy the files manually)
did you go into each directory (move_moveit, moveo_moveit_config, moveo_urdf) and run CMake?
There is a CMakeLists.txt in each of those directories, which appear to install\configure files etc.
The thing is that there is a file: mmoveo_ros/moveo_moveit/msg/ArmJointState.msg
which needs to go somewhere. That somewhere is the location of custom message headers.
It is what will make make_libraries.py generate moveo_moveit/ArmJointState.h

Additionally, there seems to be a disconnect in the tutorials:
According to the troubleshooting tips and ROS IDE Setup tutorial, you should be running:
Code: [Select]
rosrun rosserial_arduino make_libraries.py

However, the  ROS Adding Other Messages tutorial suggests that this has been superseded by:
Code: [Select]
rosrun rosserial_client make_libraries <path_to_libraries>

*** Edit ***
If you run CMake after reading this post, remember to re-build ros_lib (ie delete the old one, build a new one as per troubleshooting and tutorials)








7
Project Guidance / unable to upload compiled sket...
Last post by trpted47 - Today at 06:04 am
I am having a problem uploading a sketch that has been compiled on an uno. I have uploaded other sketches to this board before without incident but when I try to up load this sketch I receive the following error message: avrdude:stk500.getsync():not in sync:resp=0x37
I am using windows 7 64bit OS. I looked at the faqs that seemed related but nothing that I tried has helped.
8
Project Guidance / Graph a single line from analo...
Last post by PaulDLCMx - Today at 05:57 am
Hello, thanks for view my post.

I'm triyng to make a graph in a 3.5 TFT LCD SHIELD from an analog read and what I get is a bis section of the screen being filled with the line, but I need a single line, could be just a pixel of width.

The graph I try to see must be between 19 mm and 19 mm, just in the middle of the Y axis, actually I have solved this but the graph fills half of the screen and I can't get how to make just a line, just like when you open the Serial Plotter. I'm using a TFT that has the ILI9486/ILI9488 chip, and I made this run with the MCUFRIEND_kbv.h library. I attach the code and a picture of how my graph is.


Code: [Select]
#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
#include <Time.h>
MCUFRIEND_kbv tft;

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

int xPos = 0;
int n=0;

int16_t ht = 16, top = 3, line, lines = 15, scroll;

void setup(){
  tft.reset();
    uint16_t id = tft.readID();
    tft.begin(id);
    tft.setRotation(1);
    tft.fillScreen(BLACK);
    tft.setTextColor(WHITE);
     }

void loop(){
  float sensor = analogRead(A5);
  float volt=sensor*5/1024;
  //If chnages to map(sensor,0,1023....) it will fill all the pot ohm value
  float graphHeight = map(sensor,410,614,0,tft.height());
  tft.drawLine(xPos, tft.height() - graphHeight, xPos, tft.height(),WHITE);
  if (xPos >= 480) {
    xPos = 20;
    tft.fillScreen(BLACK);
    tft.setCursor(120,10);
    tft.print("Seismic Wave Sensor");
  tft.setTextSize(2);
  tft.setTextColor(WHITE);
   tft.setCursor(120,300);
  tft.print("INGENIERIA GEOFISICA");
  tft.drawLine(20,60,20,260,WHITE);
  tft.setTextSize(2);
  tft.setTextColor(WHITE);
  tft.setCursor(30,50);
  tft.print("19 mm");
  tft.setTextSize(2);
  tft.setTextColor(WHITE);
  tft.setCursor(30,260);
  tft.print("19 mm");
  }
  else {
    xPos++;
      }
   delay(16);
}
  



I think my problem could be in the part of graphHeight or the tft.drawLine, but I have been using Arduino for short time, and I know you are experts in this. Please I really need help  :(

9
Project Guidance / Re: Checking button state when...
Last post by Delta_G - Today at 05:54 am
Quote
I would like to implement into the code that if a certain switch is on then the sound will play, but if the switch is turned off then the sound wont play.
If your question is about doing this with a switch and a continuous sound, then why did you post code about a ultrasonic sensor?  Did you post the wrong code?  Can you describe the requirements a little more carefully?
10
Sensors / Re: What is a quick temperatur...
Last post by MorganS - Today at 05:44 am
I've got some thermistors with lead wires so thin that they are almost invisible to the naked eye. Thinner than a hair; smaller than any thermocouple I've seen. That has a fairly good response to rapid changes in air temperature. I forget where I got them or the part number.

An IR thermometer can have a faster response as it's measuring the temperature of things, not its own temperature.
Pages: [1] 2 3 ... 10