Вы находитесь на странице: 1из 4

MEMO

TO: Sparky Aid Designs


From: Ivan Nosov
Date: 26MAR2019

RE: Automation Code

​As stated in the last memo, I need to design a circuit that controls the interior lighting.
Unfortunately we can't perform rescue operations in a middle of perfect sunny day. More often
than not the operations will be conducted around the clock, that means some of the crew will be
working in the middle of the night. For the rescue crew it is very important not to lose their night
vision during the night operations. It takes about 30 minutes for an average person to get
adjusted to the dark. Time is a luxury during a catastrophe.
This circuit has to control the lighting in a way that it is bright in the cabin during the day and
red lighting in the night time. This circuit has to have an override function, a manual mode, just
in case the crew needs bright lights at night time. This can happen if medics are administering
first aid during the flight. To accommodate this, the main interface will have 2 switches. The first
one will swap between automatic mode and manual, the second between night and daytime
lighting.
The automated feature will have the module utilise the photo sensor that will be attached on
the exterior of the aircraft to determine the brightness. By putting 5 volts through one lead of the
sensor and attaching the other to, both, a 10k ohm resistor that goes to ground, and analog input
on the Arduino board, we get a basic voltmeter. The output values range between 54(dark) and
974(bright). I chose 500 as the point of change from bright white to dim red light, just as it starts
to get dark outside.
The following is the picture of the schematic

The following image has the breakdown of all the components used. And the code that follows.

REFERENCE - voltage reading set up

https://www.instructables.com/id/Arduino-Reading-Analog-Voltage/
3/26/2019 Circuits Incredible Jaiks-Juttuli | Tinkercad

Incredible Jaiks-Juttuli All changes saved


Privacy settings

Component List Code Start Simulation Export


View Download
Share
Layers
CSV

This is an Electronics Lab design, you can only edit and add components
Components in the Lab View.
All
Name Quantity Component

Search
U1 1 Arduino Uno R3

R1 1 Photoresistor General

S1
2 Slideswitch
S2

Dnightlight 1 Red LED


Resistor Capacitor
Ddaylight 1 White LED

R2
2 60 Ω Resistor
R3

R5 1 10 kΩ Resistor

Polarized Diode
Capacitor
Finishing

Zener Diode Inductor

Input

https://www.tinkercad.com/things/9GMHDw1Omq3-incredible-jaiks-juttuli/editel?tenant=circuits 1/1
3/26/2019 incredible_jaiks_juttuli1 (7).ino

//first I need to identify all connections that the


int red = 3; //module will interract with.
int white = 2;
float sensorRead =0; //this is the photosencor, since there is more than one input
//(analog) I have designated it as float.
int switchState1 =0; //Primary switch, top one. swap between automatic and manual.
int switchState2 =0; //Secondary swithc, manual controlls.

void setup()
// here I specify the connection to the module is an input or
{ //an output.
pinMode(A0, INPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(12, INPUT);
pinMode(13, INPUT);
Serial.begin(96000); //de-bugging script taught in class to enable the serial monitor.
}

void loop()
{
switchState2 = digitalRead(12); //tell the module to keep updating itself of the current input
switchState1 = digitalRead(13); //from the switches, is it a HIGH (5V) or LOW(0V).
{
if(switchState1 ==LOW) //so I have 2 switches, this one switches between automatic
{ digitalWrite(8, LOW); //and manual controll. If the signal is LOW to pin 8, the
sensorRead = analogRead(A0); //system goes into automatic mode.
//Serial.println(sensorRead);
if(sensorRead <500) //The lowest value from the photosensor is 54(dark), the
digitalWrite(red, HIGH); //highest 974(bright). 500 is when it is starting to get
digitalWrite(white, LOW); //dark, good time to swap to night light. 2 "if" statements are
if(sensorRead >=500) //here for the module to know what to do at different paramiters.
digitalWrite(white, HIGH);
digitalWrite(red, LOW);
}
if(switchState1 ==HIGH) //When the primary switch, the top one, is in HIGH the system goes
{ //in manual mode. In order to make sure that no light remains on,
digitalWrite(white, LOW); //a quick program to shut them down prior to the next step.
digitalWrite(red, LOW);
}
}
if(switchState1 ==HIGH && switchState2 ==HIGH)//To make sure that the manual controlls doesnt
{ digitalWrite(white, HIGH); //effect the primary switch, I have put in 2
} //requirnments that must be met. One, Primary switch
{ //must be in Manual and Secondary must be set to High
if(switchState1 ==HIGH && switchState2 ==LOW) //Same comment as above, exept secondary set to LOW.
{ digitalWrite(red, HIGH);
}
}}

file:///C:/Users/Ivan/Downloads/incredible_jaiks_juttuli1%20(7).ino 1/1

Вам также может понравиться