arduino sensor
-
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); }
-
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); }
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
-
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); }
-
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); }
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
-
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
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
-
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
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 2void 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