eightball009
Published © MPL-2.0

4-Channel Photoresistor

I have a semester project and I want to use a 4-channel photoresistor to control two bi-directional motors.

BeginnerShowcase (no instructions)1,026
4-Channel Photoresistor

Things used in this project

Hardware components

Resistor 1k ohm
Resistor 1k ohm
×1
Capacitor 1 µF
Capacitor 1 µF
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Materia 101
Arduino Materia 101

Story

Read more

Schematics

schematic

Screen pic from TinkerCad

Code

4 Chan Photo Resistor

Arduino
I am using this for my semester project. I am trying to get the second channel to work, hopefully when I do, chan 3 and 4 will work also
int tlPin = A0;
int trPin = A1;
long result = 0;
void setup()
{
  Serial.begin(9600);
  Serial.println("start");
}
void loop()
{
  Serial.print("TL");
  Serial.println( RCtime(tlPin));
  delay(10);
}
long RCtime(int tlPin)
{
  long result = 0;
  pinMode(tlPin, OUTPUT);
  digitalWrite(tlPin, HIGH);
  delay(1);
  pinMode(tlPin, INPUT);
  digitalWrite(tlPin, LOW);
  while (digitalRead(tlPin));
}
{
  Serial.print("TR");
  Serial.println(RCtime(trPin));
  delay(10);
}
long RCtime(int(trPin)) 
{ 
  long result = 0;
  pinMode(trPin, OUTPUT);
  digitalWrite(trPin, HIGH);
  delay(1);
  pinMode(trPin, INPUT);
  digitalWrite(trPin, LOW);
  while (digitalRead(trPin))
}

Credits

eightball009
0 projects • 0 followers

Comments