Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. arduino sensor

arduino sensor

Scheduled Pinned Locked Moved C / C++ / MFC
htmlcomhardwareiothelp
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12369614
    wrote on last edited by
    #1

    Hello, I am having trouble with my current project and need your help. Weight sensor is is connected to arduino uno board and to several light sources. goal is: sensor activated-mode1, sensor unactive-mode 2 for 5 seconds. Mode 1 is blinking light and mode 2 is normal light. I have written code sensor activation, for mode1 and mode 2 but it cant get it to work. What im i missing? sensor : (www.elecrow.com/weight-sensor-kit-3kg-p-883.html) code: sensor activation: #include <Hx711.h> #define LED 6 #define ADC1 A2 #define ADC2 A3 #define THRESHOLD 100. Hx711 scale(ADC1, ADC2); void setup() { pinMode(LED, OUTPUT); } void loop() { digitalWrite(LED, HIGH); delay(500); if(scale.getGram() > THRESHOLD) digitalWrite(LED, LOW); delay(500); } mod1 blinking int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(500); // wait } mod 2 light for 5 sec int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(0); digitalWrite(led, LOW); delay(5000); }

    D L S 3 Replies Last reply
    0
    • U User 12369614

      Hello, I am having trouble with my current project and need your help. Weight sensor is is connected to arduino uno board and to several light sources. goal is: sensor activated-mode1, sensor unactive-mode 2 for 5 seconds. Mode 1 is blinking light and mode 2 is normal light. I have written code sensor activation, for mode1 and mode 2 but it cant get it to work. What im i missing? sensor : (www.elecrow.com/weight-sensor-kit-3kg-p-883.html) code: sensor activation: #include <Hx711.h> #define LED 6 #define ADC1 A2 #define ADC2 A3 #define THRESHOLD 100. Hx711 scale(ADC1, ADC2); void setup() { pinMode(LED, OUTPUT); } void loop() { digitalWrite(LED, HIGH); delay(500); if(scale.getGram() > THRESHOLD) digitalWrite(LED, LOW); delay(500); } mod1 blinking int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(500); // wait } mod 2 light for 5 sec int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(0); digitalWrite(led, LOW); delay(5000); }

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Member 12403121 wrote:

      What im i missing?

      The correct forum, perhaps.

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      1 Reply Last reply
      0
      • U User 12369614

        Hello, I am having trouble with my current project and need your help. Weight sensor is is connected to arduino uno board and to several light sources. goal is: sensor activated-mode1, sensor unactive-mode 2 for 5 seconds. Mode 1 is blinking light and mode 2 is normal light. I have written code sensor activation, for mode1 and mode 2 but it cant get it to work. What im i missing? sensor : (www.elecrow.com/weight-sensor-kit-3kg-p-883.html) code: sensor activation: #include <Hx711.h> #define LED 6 #define ADC1 A2 #define ADC2 A3 #define THRESHOLD 100. Hx711 scale(ADC1, ADC2); void setup() { pinMode(LED, OUTPUT); } void loop() { digitalWrite(LED, HIGH); delay(500); if(scale.getGram() > THRESHOLD) digitalWrite(LED, LOW); delay(500); } mod1 blinking int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(500); // wait } mod 2 light for 5 sec int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(0); digitalWrite(led, LOW); delay(5000); }

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The above code means very little. Please explain exactly what the problem is. If necessary use your debugger to capture more information.

        1 Reply Last reply
        0
        • U User 12369614

          Hello, I am having trouble with my current project and need your help. Weight sensor is is connected to arduino uno board and to several light sources. goal is: sensor activated-mode1, sensor unactive-mode 2 for 5 seconds. Mode 1 is blinking light and mode 2 is normal light. I have written code sensor activation, for mode1 and mode 2 but it cant get it to work. What im i missing? sensor : (www.elecrow.com/weight-sensor-kit-3kg-p-883.html) code: sensor activation: #include <Hx711.h> #define LED 6 #define ADC1 A2 #define ADC2 A3 #define THRESHOLD 100. Hx711 scale(ADC1, ADC2); void setup() { pinMode(LED, OUTPUT); } void loop() { digitalWrite(LED, HIGH); delay(500); if(scale.getGram() > THRESHOLD) digitalWrite(LED, LOW); delay(500); } mod1 blinking int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(500); // wait } mod 2 light for 5 sec int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(0); digitalWrite(led, LOW); delay(5000); }

          S Offline
          S Offline
          Sascha Lefevre
          wrote on last edited by
          #4

          Member 12403121 wrote:

          but it cant get it to work

          Does it compile? If not, what's the compiler error message? Or if it does at least partially work, what does work, what does not?

          If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

          U 1 Reply Last reply
          0
          • S Sascha Lefevre

            Member 12403121 wrote:

            but it cant get it to work

            Does it compile? If not, what's the compiler error message? Or if it does at least partially work, what does work, what does not?

            If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

            U Offline
            U Offline
            User 12369614
            wrote on last edited by
            #5

            Hi, Sorry for not beening specific, i am new to this. the problem is the first part of the code, one for interact with sensor. I dont know how to write it. This is my best try... it is modification of several examples. I was hoping for some advices. code for mode 1 and 2 work Just fine i Just cant connect it all for sensor to recognize. hope i explain it better tjan last time

            L 1 Reply Last reply
            0
            • U User 12369614

              Hi, Sorry for not beening specific, i am new to this. the problem is the first part of the code, one for interact with sensor. I dont know how to write it. This is my best try... it is modification of several examples. I was hoping for some advices. code for mode 1 and 2 work Just fine i Just cant connect it all for sensor to recognize. hope i explain it better tjan last time

              L Offline
              L Offline
              leon de boer
              wrote on last edited by
              #6

              The only thing I can see change between the two modes is the delay

              // COMBINED MODE 1 & 2 CODE FROM WHAT YOU GAVE

              int led = 13;
              int mode = 1; // Set mode 1 start
              static int delay1[2] = {500, 0}; // 500ms delay for mode 1, 0 ms delay for mode 2
              static int delay2[2] = {500, 5000}; // 500ms delay for mode 1, 5000 ms delay for mode 2

              void setup() {
              pinMode(led, OUTPUT);
              }

              void loop() {
              digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
              delay(delay1[mode-1]); // wait depending on mode .. dont forget arrays start at zero in c
              digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
              delay(delay2[mode-1]); // wait depending on mode .. dont forget arrays start at zero in c

              // this is just to show off both modes usually something does this change
              // this code simple forces alternation between the 2 modes
              if (mode == 1) mode = 2; else mode = 1;
              }

              In vino veritas

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups