So i Developed this app on MIT app inventor and i made a simple If Button 1 clicked call Bluetooth send text “1”
And i watched Electronoobs video about how to controll lamps and stuff, i need a 9 V pump and im using a transistor as a switch.
And i tried BTSerial from softwareserial, if it looks mesy… im kinda noob…
#include <SoftwareSerial.h>´
#include <Wire.h>
#include <RtcDS3231.h>
SoftwareSerial BTSerial(4,5);
RtcDS3231 Rtc(Wire);
int sensorPin = A0;
int sensorValue = 0;
int percent = 0;
int Pump = 4;
int Recieved = 0;
int Pump_state = 0;
void setup() {
Serial.begin(9600);
pinMode(Pump, OUTPUT);
Rtc.Begin();
Rtc.Enable32kHzPin(false);
Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeNone);
BTSerial.begin(38400);
}
void loop() {
digitalWrite(Pump, LOW);
sensorValue = analogRead(sensorPin);
percent = convertToPercent(sensorValue);
printValuesToSerial();
delay(1000);
RtcTemperature temp = Rtc.GetTemperature();
if(BTSerial.read() > 0) {
Serial.print(BTSerial);
}
if(Serial.available() > 0){
Recieved = Serial.read();
}
if(Pump_state == 0 && Recieved == “1”) {
digitalWrite(Pump, HIGH);
Pump_state=1;
Recieved=0;
delay(10000);
}
if(percent > 50){
digitalWrite(Pump, HIGH);
delay(1);
if(percent > 50){
digitalWrite(Pump, LOW);
delay(2700000);
}
}
}
int convertToPercent(int value)
{
int percentValue = 0;
percentValue = map(value, 1023, 0, 0, 100);
return percentValue;
}
void printValuesToSerial()
{
RtcTemperature temp = Rtc.GetTemperature();
temp.Print(Serial);
Serial.print(“C”);
Serial.print("`");
Serial.print(percent);
Serial.print("%");
delay(5000);
}
PLANTA.ino (1.35 KB)
system
#2
Is there a question?
An inkling that this may not be the right section of the forum to post this?
i need help with how i can make a if out of that signal on my arduino
ok i will try...
so i want so that when i click the button on my phone i want the pump to run... using the serial
system
#6
if(percent > 50){
digitalWrite(Pump, HIGH);
delay(1);
if(percent > 50){
digitalWrite(Pump, LOW);
delay(2700000);
}
}
Explain what how you think the logic of that works.
Why does it have two "if"s, when one would work just as well.
well that´s me being stupid
system
#8
Ok.
Come back when you’ve taken your stupid head off, and screwed on a sensible one.
#include <SoftwareSerial.h>´
#include <Wire.h>
#include <RtcDS3231.h>
SoftwareSerial BTSerial(4,5);
RtcDS3231 Rtc(Wire);
int sensorPin = A0;
int sensorValue = 0;
int percent = 0;
int Pump = 4;
int Recieved = 0;
int Pump_state = 0;
void setup() {
Serial.begin(9600);
pinMode(Pump, OUTPUT);
Rtc.Begin();
Rtc.Enable32kHzPin(false);
Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeNone);
BTSerial.begin(38400);
}
void loop() {
digitalWrite(Pump, LOW);
sensorValue = analogRead(sensorPin);
percent = convertToPercent(sensorValue);
printValuesToSerial();
delay(1000);
RtcTemperature temp = Rtc.GetTemperature();
if(BTSerial.read() > 0) {
Serial.print(BTSerial);
}
if(Serial.available() > 0){
Recieved = Serial.read();
}
if(Pump_state == 0 && Recieved == “1”) {
digitalWrite(Pump, HIGH);
Pump_state=1;
Recieved=0;
delay(10000);
}
if(percent > 50){
digitalWrite(Pump, HIGH);
delay(1);
digitalWrite(Pump, LOW);
delay(2700000);
}
}
int convertToPercent(int value)
{
int percentValue = 0;
percentValue = map(value, 1023, 0, 0, 100);
return percentValue;
}
void printValuesToSerial()
{
RtcTemperature temp = Rtc.GetTemperature();
temp.Print(Serial);
Serial.print(“C”);
Serial.print("`");
Serial.print(percent);
Serial.print("%");
delay(5000);
}
system
#10
if(percent > 50){
digitalWrite(Pump, HIGH);
delay(1);
digitalWrite(Pump, LOW);
delay(2700000);
Does the pump latch the one millisecond pulse?
Can you start using code tags when you post code, so we don't miss anything?
the 1 delay is just me wanting to work with it at the moment, in the end it is suposed to be 20000