I have been working on a DNA synthesizer using several solenoid valves and an Arduino Uno. The synthesizer works by pumping different reagents through each solenoid valves according to a sequence of characters (being a compilation of nucleotide letters A, G, T, C, and/or U) given by a text file on a micro SD card. Here is the circuit I have currently:
Here is the current code I have been working with for my Arduino Uno:
/* MIT Open-Source LICENSE:
*
* Copyright 2018 Charles Grassin
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// PINS
#include <Arduino.h>
#include <stdint.h>
#include <SD.h>
#include <SPI.h>
#include <AFMotor.h>
#define MAX_LINE_LEN 80
#include <LiquidCrystal.h>
#define SERIAL_BUFFER_LENGTH 1
int solenoidPin1 = 2;
int solenoidPin2 = 3;
int solenoidPin3 = 4;
int solenoidPin4 = 5;
int solenoidPin5 = 6;
int solenoidPin6 = 7;
int solenoidPin7 = 8;
int solenoidPin8 = 9;
char serialBuffer[SERIAL_BUFFER_LENGTH];
uint8_t currentIndex=0;
void setup() {
const int cs = 10;
if (!SD.begin(cs))
{
Serial.println("Card failed to initialize, or not present");
return;
}
Serial.println("card initialized.");
// open the file named ourfile.txt
File myfile = SD.open("oligo.txt");
// if the file is available, read the file
if (myfile)
{
while (myfile.available())
{
Serial.write(myfile.read());
}
myfile.close();
}
// if the file cannot be opened give error report
else {
Serial.println("error opening the text file");
}
Serial.print("Initializing card...");
pinMode(solenoidPin1, OUTPUT);
pinMode(solenoidPin2, OUTPUT);
pinMode(solenoidPin3, OUTPUT);
pinMode(solenoidPin4, OUTPUT);
pinMode(solenoidPin5, OUTPUT);
pinMode(solenoidPin6, OUTPUT);
pinMode(solenoidPin7, OUTPUT);
pinMode(solenoidPin8, OUTPUT);
}
int incomingByte = 0; // for incoming serial data
void loop() {
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
{
if (Serial.read() == 'A'||'a'){
digitalWrite(solenoidPin1, HIGH); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin1, LOW); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin6, HIGH);
delay(1000);
digitalWrite(solenoidPin6, LOW);
digitalWrite(solenoidPin7, HIGH);
delay(1000);
digitalWrite(solenoidPin7, LOW);
}
}
{
if (Serial.read() == 'G'||'g') { //G||g
digitalWrite(solenoidPin2, HIGH); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin2, LOW); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin6, HIGH);
delay(1000);
digitalWrite(solenoidPin6, LOW);
digitalWrite(solenoidPin7, HIGH);
delay(1000);
digitalWrite(solenoidPin7, LOW);
}
}
{
if (Serial.read() == 'C'||'c') {
digitalWrite(solenoidPin3, HIGH); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin3, LOW); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin6, HIGH);
delay(1000);
digitalWrite(solenoidPin6, LOW);
digitalWrite(solenoidPin7, HIGH);
delay(1000);
digitalWrite(solenoidPin7, LOW);
}
}
{
if (Serial.read() == 'T'||'t'){
digitalWrite(solenoidPin4, HIGH); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin4, LOW); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin6, HIGH);
delay(1000);
digitalWrite(solenoidPin6, LOW);
digitalWrite(solenoidPin7, HIGH);
delay(1000);
digitalWrite(solenoidPin7, LOW);
}
}
{
if (Serial.read() == 'U'||'u'){
digitalWrite(solenoidPin5, HIGH); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin5, LOW); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin6, HIGH);
delay(1000);
digitalWrite(solenoidPin6, LOW);
digitalWrite(solenoidPin7, HIGH);
delay(1000);
digitalWrite(solenoidPin7, LOW);
}
}
{
if (Serial.read() == '\0') {
digitalWrite(solenoidPin8, HIGH); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin8, LOW); //Switch Solenoid ON
delay(1000); //Wait 1 Second
}
}
}
I can't seem to figure out what is going wrong with the design, but I have a feeling its my "if else" statement code for each solenoid valve. They are supposed to activate when the given letter is read off of the SD card text file, for example solenoidPin1 corresponds to letter A, while solenoidPin6 and solenoidPin7 are reagents that are supposed turn on after each nucleotide solenoid is activated. I am not sure if the current statements are fulfilling this purpose, and would appreciate any feedback.