Leyla
Published © CC BY-NC-SA

Ethafa

A maker kit designed for Egyptian girls who want to learn electronics.

BeginnerShowcase (no instructions)3,640
Ethafa

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×5
Photo resistor
Photo resistor
×6
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×2
LED (generic)
LED (generic)
×5
LCD Screen
×1
LED 10 Segments bargraph (red, yellow, green)
×1
Jumpers
×1
Resistors
×1
Servos (Tower Pro MG996R)
×1
Piezo Buzzer
×1
Switch battery
×5
Breadboard (generic)
Breadboard (generic)
×5
Mini breadboard
×5

Story

Read more

Code

Alriya.ino

Arduino
// source: http://www.electroschematics.com

//Photoresistor
int readPinAnalog = A1;
int writePinPwm = 11;

//LEDBAR
//declares all the pin connections to the arduino board
const int LED1= 13; 
const int LED2= 12;
const int LED3= 9;
const int LED4= 8;
const int LED5= 7;
const int LED6= 6;
const int LED7= 5;
const int LED8= 4;
const int LED9= 3;
const int LED10= 2;
const int potentiometer= A0;

int value=0;

//declares the LEDs as outputs and the potentiometer as inputs
//also creates a Serial Monitor so that we can see what the actually analog value is
void setup()
{
//Photoresistor
pinMode(readPinAnalog, INPUT);
pinMode(writePinPwm, OUTPUT);

//LEDBAR  
pinMode(LED1, OUTPUT); 
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode (LED5, OUTPUT);
pinMode (LED6, OUTPUT);
pinMode (LED7, OUTPUT);
pinMode (LED8, OUTPUT);
pinMode (LED9, OUTPUT);
pinMode (LED10, OUTPUT);
pinMode (potentiometer, INPUT);
Serial.begin(9600);
}

void loop()
{
//Photoresistor
 int readAnalogValue = analogRead(readPinAnalog);
 int tmp = readAnalogValue / 15; 
 analogWrite(writePinPwm,tmp);
 delay(100);

//LEDBAR   
value= analogRead(potentiometer);
Serial.println(value);

//all LEDs are off
if (value == 0)
{
digitalWrite (LED1, LOW);
digitalWrite (LED2, LOW);
digitalWrite (LED3, LOW);
digitalWrite (LED4, LOW);
digitalWrite (LED5, LOW);
digitalWrite (LED6, LOW); 
digitalWrite (LED7, LOW);
digitalWrite (LED8, LOW); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 1 LED
if ((value >0) && (value < 103))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, LOW);
digitalWrite (LED3, LOW);
digitalWrite (LED4, LOW); 
digitalWrite (LED5, LOW);
digitalWrite (LED6, LOW); 
digitalWrite (LED7, LOW);
digitalWrite (LED8, LOW); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 2 LEDs
if ((value >= 103) && (value < 205))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, LOW);
digitalWrite (LED4, LOW); 
digitalWrite (LED5, LOW);
digitalWrite (LED6, LOW); 
digitalWrite (LED7, LOW);
digitalWrite (LED8, LOW); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 3 LEDs
if ((value >= 206) && (value < 308))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
digitalWrite (LED4, LOW); 
digitalWrite (LED5, LOW);
digitalWrite (LED6, LOW); 
digitalWrite (LED7, LOW);
digitalWrite (LED8, LOW); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 4 LEDs
if ((value >= 309) && (value < 410))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
digitalWrite (LED4, HIGH); 
digitalWrite (LED5, LOW);
digitalWrite (LED6, LOW); 
digitalWrite (LED7, LOW);
digitalWrite (LED8, LOW); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 5 LEDs
if ((value >= 411) && (value < 512))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
digitalWrite (LED4, HIGH); 
digitalWrite (LED5, HIGH);
digitalWrite (LED6, LOW); 
digitalWrite (LED7, LOW);
digitalWrite (LED8, LOW); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 6 LEDs
if ((value >= 513) && (value < 615))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
digitalWrite (LED4, HIGH); 
digitalWrite (LED5, HIGH);
digitalWrite (LED6, HIGH); 
digitalWrite (LED7, LOW);
digitalWrite (LED8, LOW); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 7 LEDs
if ((value >= 616) && (value < 717))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
digitalWrite (LED4, HIGH); 
digitalWrite (LED5, HIGH);
digitalWrite (LED6, HIGH); 
digitalWrite (LED7, HIGH);
digitalWrite (LED8, LOW); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 8 LEDs
if ((value >= 718) && (value < 819))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
digitalWrite (LED4, HIGH); 
digitalWrite (LED5, HIGH);
digitalWrite (LED6, HIGH); 
digitalWrite (LED7, HIGH);
digitalWrite (LED8, HIGH); 
digitalWrite (LED9, LOW);
digitalWrite (LED10, LOW); 
}

//lights up 9 LEDs
if ((value >= 820) && (value < 921))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
digitalWrite (LED4, HIGH); 
digitalWrite (LED5, HIGH);
digitalWrite (LED6, HIGH); 
digitalWrite (LED7, HIGH);
digitalWrite (LED8, HIGH); 
digitalWrite (LED9, HIGH);
digitalWrite (LED10, LOW); 
}

//lights up 10 LEDs
if ((value >= 922) && (value < 1023))
{
digitalWrite (LED1, HIGH);
digitalWrite (LED2, HIGH);
digitalWrite (LED3, HIGH);
digitalWrite (LED4, HIGH); 
digitalWrite (LED5, HIGH);
digitalWrite (LED6, HIGH); 
digitalWrite (LED7, HIGH);
digitalWrite (LED8, HIGH); 
digitalWrite (LED9, HIGH);
digitalWrite (LED10, HIGH); 
}
}

Eulim.ino

Arduino
// Pinmappings  
int greenPin1 =  5; //RGB LED 1
int redPin1 =  6; //RGB LED 1
int bluePin1 =  3; //RGB LED 1
int redPin2 =  9; //RGB LED 2
int greenPin2 =  10; //RGB LED 2
int bluePin2 =  11; //RGB LED 2

int valRedL = 255;
int valGreenL = 255;
int valBlueL = 255;

int valRedH = 120;
int valGreenH = 240;
int valBlueH = 230;


// Settings
int Photoresistor = A1; // Photoresistor / Lightsensor set to 0
int ledDelay = 150; // Xms delay

// The setup() method runs once, when the sketch starts defining serial baudrate and pin type.

void setup()   {
 // setup serial communication rate
 Serial.begin(9600);

 // initialize the pins as an outputs
 pinMode(redPin1, OUTPUT);
 pinMode(greenPin1, OUTPUT);
 pinMode(bluePin1, OUTPUT);
 pinMode(redPin2, OUTPUT);
 pinMode(greenPin2, OUTPUT);
 pinMode(bluePin2, OUTPUT);

 switchOff();
 
}

// The loop starts running the program

void loop()  {
 // Read photoresistor
 Photoresistor = analogRead(A1);

 //Photoresistor = 1000;


 if ( Photoresistor > 450 ) {
 Serial.print("Too dark - LED ON - value is: ");
 Serial.println(Photoresistor);
 // Turn the LEDs on
 analogWrite(redPin1, valRedH);
 analogWrite(bluePin1, valBlueH);
 analogWrite(greenPin1, valGreenH);
 analogWrite(greenPin2, valGreenH);
 analogWrite(bluePin2, valBlueH);
 analogWrite(redPin2, valRedH);
 delay(50);
 }

 /*
 if ( Photoresistor >= 830 && Photoresistor <= 960 ) {
 Serial.print("The light is on - LED OFF - value is: ");
 Serial.println(Photoresistor);
 // Turn all LEDs off
 analogWrite(greenPin1, valGreenL);
 analogWrite(bluePin1, valBlueL);
 analogWrite(redPin1, valRedL);
 analogWrite(greenPin2, valGreenL);
 analogWrite(bluePin2, valBlueL);
 analogWrite(redPin2, valRedL);
 delay(50); }
 */
 
 else {

  switchOff();
 //Serial.print("Agh too much light i am blind! Is the police here? - value is: ");
 Serial.println(Photoresistor);
 // Make LED blinking police lights
 analogWrite(redPin1, valRedL); // turn the red light on LED 1
 analogWrite(bluePin2, valBlueL); // turn the blue light on LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(redPin1, valRedH); // turn the red light off LED 1
 analogWrite(bluePin2, valBlueH); // turn the blue light off LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(redPin1, valRedL); // turn the red light on LED 1
 analogWrite(bluePin2, valBlueL); // turn the blue light on LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(redPin1, valRedH); // turn the red light off LED 1
 analogWrite(bluePin2, valBlueH); // turn the blue light off LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(redPin1, valRedL); // turn the red light on LED 1
 analogWrite(bluePin2, valBlueL); // turn the blue light on LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(redPin1, valRedH); // turn the red light off LED 1
 analogWrite(bluePin2, valBlueH); // turn the blue light off LED 2
 delay(ledDelay); // wait 50 ms
 delay(100); // delay midpoint by 100ms
 analogWrite(bluePin1, valBlueL); // turn the blue light on LED 1
 analogWrite(redPin2, valRedL); // turn the red light on LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(bluePin1, valBlueH); // turn the blue light off LED 1
 analogWrite(redPin2, valRedH); // turn the red light off LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(bluePin1, valBlueL); // turn the blue light on LED 1
 analogWrite(redPin2, valRedL); // turn the red light on LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(bluePin1, valBlueH); // turn the blue light off LED 1
 analogWrite(redPin2, valRedH); // turn the red light off LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(bluePin1, valBlueL); // turn the blue light on LED 1
 analogWrite(redPin2, valRedL); // turn the red light on LED 2
 delay(ledDelay); // wait 50 ms
 analogWrite(bluePin1, valBlueH); // turn the blue light off LED 1
 analogWrite(redPin2, valRedH); // turn the red light off LED 2
 delay(ledDelay); // wait defined ms 
 }
}

void switchOff() {
  
  analogWrite(redPin1, valRedL);
  analogWrite(bluePin1, valBlueL);
  analogWrite(greenPin1, valGreenL);
  analogWrite(greenPin2, valGreenL);
  analogWrite(bluePin2, valBlueL);
  analogWrite(redPin2, valRedL);

}

Teqia.ino

Arduino
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

//Pet light sensor
int petVal;
const int petPin = A0;
const int eyesPin = 9;

void setup() {
 // set up the LCD's number of columns and rows:
 lcd.begin(16, 2);
 // Print a message to the LCD.
 lcd.print("!");

 pinMode (eyesPin, OUTPUT);
 digitalWrite (eyesPin, LOW);

}

void loop() {
  
  //Pet light sensor
  petVal = map(analogRead(petPin), 0, 1023, 0, 210);
  analogWrite(eyesPin, petVal);

  //Serial.println(petVal);

   // set the cursor to column 0, line 1
   // (note: line 1 is the second row, since counting begins with 0):
   lcd.setCursor(0, 1);
   // print the number of seconds since reset:
   lcd.print(millis() / 1000);

}

Fanin.ino

Arduino
 //Pet light sensor
 int petVal;
 const int petPin = A5;
 const int eyesPin = 10;


 //PiezoBuzzer
 int buzzerSensorValue;
 int sensorLow;
 int sensorHigh;
 int buzzerPitch;
 const int buzzerPin = 6;
 const int buzzerSensorPin = A0;

void setup() {

 //Pet light sensor
 pinMode(eyesPin, OUTPUT);

 //PiezoBuzz
 pinMode(buzzerPin, OUTPUT);

 digitalWrite(eyesPin, HIGH);
 delay(100);
 digitalWrite(eyesPin, LOW);

 Serial.begin(9600);

  // calibrate the buzzer light sensor
  while (millis() < 3000) {
    buzzerSensorValue = analogRead(buzzerSensorPin);
    
    if (buzzerSensorValue > sensorHigh) {
      sensorHigh = buzzerSensorValue;
    }
    if (buzzerSensorValue < sensorLow) {
      sensorLow = buzzerSensorValue;
    }
  }

 Serial.print("sensorHigh: ");
 Serial.println(sensorHigh);

 Serial.print("sensorLow: ");
 Serial.println(sensorLow);

}

void loop() {

  //Pet light sensor
  petVal = map(analogRead(petPin), 0, 1023, 255, 10);
  analogWrite(eyesPin, petVal);

  //PiezoBuzz
  buzzerSensorValue = analogRead(buzzerSensorPin);
  buzzerPitch = map(buzzerSensorValue, sensorHigh, sensorLow, 100, 5000);
  
  if(buzzerSensorValue < (sensorHigh - 100)) {
    tone(buzzerPin, buzzerPitch, 10);
  } else {
    noTone(buzzerPin);
  }
  
  delay (100);

}

Handas.ino

Arduino
#include <Servo.h>
Servo myservo;

//Photoresistor
int readPinAnalog = A1;
int writePinPwm = 11;

//Servo
const int switchPin = 2;
const int motorPin = 9;
int switchState = 0;

void setup() {
 //Photoresistor
 pinMode(writePinPwm, OUTPUT);

 //Servo
 //myservo.attach(motorPin);
 pinMode(switchPin, INPUT);

 //Serial.begin(9600);

}

void loop() {

  //Photoresistor
  int readAnalogValue = analogRead(readPinAnalog);
  int tmp = readAnalogValue / 15; 
  analogWrite(writePinPwm,tmp);


//Servo
 switchState = digitalRead(switchPin);

 if (switchState == HIGH) {
   //Serial.println("HIGH");
   myservo.attach(motorPin);
   myservo.write(0);
 }
 else {
  //Serial.println("LOW");
  myservo.detach();
  pinMode(motorPin, OUTPUT);
  digitalWrite(motorPin, 0);
 }

 delay(50);

}

Credits

Leyla

Leyla

0 projects • 5 followers

Comments