Hi, all
It's jeremy again:)
I've got 14 coin motor project still.
with lilypad arduino, I've got cloth and circuit already.
this is my code
#include <DFPlayer_Mini_Mp3.h>
#include <SoftwareSerial.h>
const int L1 = 12;
const int L2 = 13;
const int L3 = A0;
const int L4 = A1;
const int L5 = A2;
const int L6 = A3;
const int L7 = A4;
const int R1 = 11;
const int R2 = 10;
const int R3 = 9;
const int R4 = 8;
const int R5 = 7;
const int R6 = 6;
const int R7 = 5;
int flexSensor = A5;
void setup() {
Serial.begin(9600);
mp3Serial.begin(9600);
mp3_set_serial (mp3Serial);
delay(1);
mp3_set_volume (30);
pinMode(flexSensor, INPUT);
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(L4, OUTPUT);
pinMode(L5, OUTPUT);
pinMode(L6, OUTPUT);
pinMode(L7, OUTPUT);
pinMode(R1, OUTPUT);
pinMode(R2, OUTPUT);
pinMode(R3, OUTPUT);
pinMode(R4, OUTPUT);
pinMode(R5, OUTPUT);
pinMode(R6, OUTPUT);
pinMode(R7, OUTPUT);
}
void loop() {
int flexVal;
flexVal = analogRead(flexSensor);
if (flexVal < 4) {
//rain LESS
digitalWrite(L1, HIGH);
delay(30);
digitalWrite(L1, LOW);
delay(200);
}
else {
//rain MORE
digitalWrite(L1, HIGH);
delay(40);
digitalWrite(L1, LOW);
delay(50);
mp3_play();
delay(100000);
}
Serial.println(flexVal);
}
When flex sensor straights, flexVal increases above 4 and goes to 'else'.
Though I put 4 simple lines in coin vibrating parts.
It has 40 long codes about 30 sec.
This is my question, like this way, flexVal doesn't change till coin vibrating parts over.
Can I change this 40 long code to simple code with random function?
and How can I get out this loop right away when flexVal changed?
Sorry for the bad english but I'll awake 24 hours from now
so.. help..