Today, we mainly work on the programming part of the microplate readers. Previously, we have finished the programing for "M" code which is the movement of the motor to a specific spot, and the "L" code for lighting up and turning off of the LEDs. Today we have finished the "A" and "S" code. For the "A" code, the function is to light up specific LED or many LEDs at a time for a specific period of time. The "S" code's function is to perform a shaking movement.
Here's the basic programming:
String protocolString = "";
boolean protocolWait = false;
String parsedString = "";
int startIndex = 0;
String ledString = "";
String auxString = "";
int auxDuration = 0;
int brightInt = 0;
long brightValue = 0;
long expTime = 0;
int pumpNumb = 0;
int pumpDur = 0;
String totalString = "";
void setup() {
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
protocolString = Serial.readString();
Serial.println(protocolString);
for (int i = 0; i <= protocolString.length(); i++){ // Analyze command string one character at a time
parsedString = protocolString.substring(i,i+1);
if (parsedString == ";"){
if (protocolString.substring(startIndex, startIndex+1) == "L"){
totalString = protocolString.substring(startIndex,i);
Serial.println(totalString.length());
if (totalString.length() <= 2){
ledString = protocolString.substring(startIndex+1,i);
if (ledString == "1"){
digitalWrite(3, !digitalRead(3));
}
else if (ledString == "2"){
digitalWrite(4, !digitalRead(4));
}
else if (ledString == "3"){
digitalWrite(5, !digitalRead(5));
}
}
}
if (protocolString.substring(startIndex, startIndex+1) == "A"){
totalString = protocolString.substring(startIndex,i);
auxString = protocolString.substring(startIndex+1,startIndex+2);
auxDuration = (protocolString.substring(startIndex+2,i)).toInt();
if (auxString == "1"){
digitalWrite(3, HIGH);
delay(auxDuration);
digitalWrite(3, LOW);
}
else if (auxString == "2"){
//digitalWrite(8, !digitalRead(8));
digitalWrite(5, HIGH);
digitalWrite(4, HIGH);
delay(auxDuration);
//digitalWrite(8, !digitalRead(8));
digitalWrite(5, LOW);
digitalWrite(4, LOW);
// digitalWrite(11, HIGH);
// delay(auxDuration);
// digitalWrite(11, LOW);
}
else if (auxString == "3"){
digitalWrite(12, HIGH);
delay(auxDuration);
digitalWrite(12, LOW);
}
else if (auxString == "4"){
digitalWrite(2, HIGH);
delay(auxDuration);
digitalWrite(2, LOW);
}
Serial.println("done");
}
startIndex = i+1;
}
}
}
protocolString = "";
totalString = "";
parsedString = "";
startIndex = 0;
}
Also, we have changed the details about the gear holders and plate holder and then we have put them up together.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.