Random Thoughts

Project- Xbox Cooling System Prep- OR Logic Gate with Switch and Photocell

From my time studying Electrical Engineering, I began creating and researching the
beginning portions of future projects I was interested in building. Below is an
explanation of how OR logic Gates work when combined with a switch and a photocell.
This was used mainly in my Xbox Cooling System Project.
          This project demonstrates how an OR logic gate works using 2 different types of inputs. This is shown by turning the L.E.D.’s in the circuit on and off. This project was chosen due to a desire to fully understand the different types of logic gates and how they can be used in multiple applications. It is quite clear that using a logic gate will be very useful in my future projects such as an independent cooling system for an Xbox One. It will feature an extra fan that will turn on depending on the temperature of the console obtained from a temperature sensor. It will feature an off-setting with a green L.E.D indicator for when the console is cool, a low-speed fan setting with a yellow L.E.D indicator for when the console is warm, and finally a high-speed setting for when the console is hot with a red L.E.D indicator. This communication of temperature will be discussed further in my next post.
          This project demonstrates how an OR logic gate works using a push activated switch and a photocell on an Arduino Uno board. This project has 3 L.E.D.’s in total. There is a yellow, green, and red L.E.D. that are all connected. The L.E.D.’s will turn on if either the pushbutton switch is pressed, OR if the photocell is in a low-light environment. Because this is an OR logic gate, the L.E.D.’s will not turn on if both the pushbutton switch is pressed and the photocell senses a high amount of light. This is accomplished by using the || operator in the IF statement. || is the computer programming symbol for the logical OR function.
          There are numerous uses for a project like this such as a way to automatically turn on and off headlights in an automobile. Using this project, the headlights would only turn on if it is dark outside or the driver turns them on. The headlights would, however, not turn on if it is both dark out and the driver turns them on, as they would already be on from sensing the lack of light environment. Although this design is relatively simple, there are future upgrades that could be done to this project to give it a wider and more complex range of applications. If the L.E.D.’s were wired separately as well as making some coding changes, the L.E.D.’s could turn on individually depending on 3 temperature settings; low (green L.E.D.), medium (yellow L.E.D.), and finally high (red L.E.D.) Also with some coding changes, the previously mentioned use in an automobile’s headlights could be improved as well. The headlights could potentially be turned on automatically in a dark environment and when the pushbutton is pressed, the headlights could either get brighter or the high beams could turn on.
/* The Arduino OR Logic Gate
 Turns on an LED connected to digital
 pin 7, when pressing either a pushbutton switch or covering a photocell
 attached to pins 3 and 4
 // constants won’t change; they’re used here to
 // set pin numbers:
 int B = 3;   // the number of the B pushbutton pin
 int A = 4;   // the number of the A pushbutton pin
 const int Cout =  7;     // the number of the LED pin
 // variables will change:
 int AStatus = 0;         // variable for reading the A pushbutton status
 int BStatus = 0;         
void setup() {
 // initialize the LED pin an an output:
  pinMode(Cout, OUTPUT);
  // initialize the pushbutton pins as inputs:
  pinMode(B, INPUT);
  pinMode(A, INPUT); 
void loop(){
  // read the state of the pushbutton value:
  AStatus = digitalRead(A);
  BStatus = digitalRead(B);
  // check if the pushbuttons are pressed
  // if it is, the buttonStatus is HIGH:
  if (AStatus == HIGH || BStatus == HIGH) {
      // turn LED on:     
      digitalWrite(Cout, HIGH);
  else {
        // turn LED off:
        digitalWrite(Cout, LOW);
Truth Table

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s