Revision and new visualization system.
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
int impulsDelay = 1;
|
||||
int impulsLength = 5;
|
||||
int potValue = 1;
|
||||
int individualAfterDelay = 10;
|
||||
unsigned long i1wait = 0;
|
||||
unsigned long i2wait = 0;
|
||||
unsigned long i3wait = 0;
|
||||
|
||||
unsigned long previouscoil2trigger = 0;
|
||||
unsigned long lastcoil2trigger = 0;
|
||||
@@ -48,23 +52,14 @@ void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
Serial.flush();
|
||||
mySerial.begin(4800);
|
||||
mySerial.flush();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned long currentMillis = millis();
|
||||
// getting the pulse length from the pot
|
||||
potValue = analogRead(A0);
|
||||
impulsLength = map(potValue, 0, 1023, 0, 100);
|
||||
//potValue = analogRead(A0);
|
||||
//impulsLength = map(potValue, 0, 1023, 0, 100);
|
||||
// sending data to the displayDriver every 1s
|
||||
if (currentMillis - lastdisplaywrite >= 1000) {
|
||||
lastdisplaywrite = currentMillis;
|
||||
mySerial.print(impulsLength);
|
||||
mySerial.print(",");
|
||||
mySerial.print(lastcoil2trigger-previouscoil2trigger);
|
||||
mySerial.print('\n');
|
||||
}
|
||||
|
||||
// checking if ball detected, if yes then fire the pulse
|
||||
if (digitalRead(sensor1pin)) {
|
||||
impuls1();
|
||||
@@ -76,30 +71,41 @@ void loop() {
|
||||
}
|
||||
|
||||
void impuls1() {
|
||||
if (i1wait > millis()) {
|
||||
return;
|
||||
}
|
||||
delay(impulsDelay);
|
||||
digitalWrite(coil1pin, LOW);
|
||||
delay(impulsLength);
|
||||
digitalWrite(coil1pin, HIGH);
|
||||
Serial.print("1 ");
|
||||
Serial.println(millis());
|
||||
delay(50);
|
||||
i1wait = millis()+individualAfterDelay;
|
||||
}
|
||||
|
||||
void impuls2() {
|
||||
if (i2wait > millis()) {
|
||||
return;
|
||||
}
|
||||
delay(impulsDelay);
|
||||
digitalWrite(coil2pin, LOW);
|
||||
delay(impulsLength);
|
||||
digitalWrite(coil2pin, HIGH);
|
||||
Serial.print("2 ");
|
||||
Serial.println(millis());
|
||||
delay(50);
|
||||
previouscoil2trigger = lastcoil2trigger;
|
||||
lastcoil2trigger = millis();
|
||||
i2wait = millis()+individualAfterDelay;
|
||||
|
||||
}
|
||||
|
||||
void impuls3() {
|
||||
if (i3wait > millis()) {
|
||||
return;
|
||||
}
|
||||
delay(impulsDelay);
|
||||
digitalWrite(coil3pin, LOW);
|
||||
delay(impulsLength);
|
||||
digitalWrite(coil3pin, HIGH);
|
||||
Serial.print("3 ");
|
||||
Serial.println(millis());
|
||||
delay(50);
|
||||
i3wait = millis()+individualAfterDelay;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user