Sanmati Choudhary
Published

3D Light Up Brain Model

A light up model of the human brain to represent neuroimaging using the Arduino.

BeginnerWork in progress1 hour2,630
3D Light Up Brain Model

Things used in this project

Story

Read more

Code

Brain Lights

C/C++
Arduino code for the Lights and push buttons
/* Basic Digital Read
 * ------------------ 
 *
 * turns on and off a light emitting diode(LED) connected to digital  
 * pin 13, when pressing a pushbutton attached to pin 7. It illustrates the
 * concept of Active-Low, which consists in connecting buttons using a
 * 1K to 10K pull-up resistor.
 *
 * Created 1 December 2005
 * copyleft 2005 DojoDave <http://www.0j0.org>
 * http://arduino.berlios.de
 *
 */

int ledPinred = 13; // choose the pin for the LED
int inPinred = 7;   // choose the input pin (for a pushbutton)
int valred = 0;     // variable for reading the pin status
int ledPinwhite = 8; // choose the pin for the LED
int inPinwhite = 4;   // choose the input pin (for a pushbutton)
int valwhite = 0;     // variable for reading the pin status
int ledPingreen = 10; // choose the pin for the LED
int inPingreen = 5;   // choose the input pin (for a pushbutton)
int valgreen = 0;     // variable for reading the pin status
int ledPinyell = 12; // choose the pin for the LED
int inPinyell = 6;   // choose the input pin (for a pushbutton)
int valyell = 0;     // variable for reading the pin status


void setup() {
  pinMode(ledPinred, OUTPUT);  // declare LED as output
  pinMode(inPinred, INPUT);    // declare pushbutton as input
  pinMode(ledPinwhite, OUTPUT);  // declare LED as output
  pinMode(inPinwhite, INPUT);    // declare pushbutton as input
  pinMode(ledPingreen, OUTPUT);  // declare LED as output
  pinMode(inPingreen, INPUT);    // declare pushbutton as input
  pinMode(ledPinyell, OUTPUT);  // declare LED as output
  pinMode(inPinyell, INPUT);    // declare pushbutton as input
}

void loop(){
  valred = digitalRead(inPinred);  // read input value
  if (valred == HIGH) {         // check if the input is HIGH (button released)
    digitalWrite(ledPinred, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPinred, HIGH);  // turn LED ON
  }
  valwhite = digitalRead(inPinwhite);  // read input value
  if (valwhite == HIGH) {         // check if the input is HIGH (button released)
    digitalWrite(ledPinwhite, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPinwhite, HIGH);  // turn LED ON
  }
  valgreen = digitalRead(inPingreen);  // read input value
  if (valgreen == HIGH) {         // check if the input is HIGH (button released)
    digitalWrite(ledPingreen, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPingreen, HIGH);  // turn LED ON
  }
  valyell = digitalRead(inPinyell);  // read input value
  if (valyell == HIGH) {         // check if the input is HIGH (button released)
    digitalWrite(ledPinyell, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPinyell, HIGH);  // turn LED ON
  }
}

Credits

Sanmati Choudhary

Sanmati Choudhary

6 projects • 9 followers
Junior at Farmington High School

Comments