Devices & Components
Arduino Uno Rev3
Arduino Soldering Kit 220V
Laser Diode, 2 Pins
Wire
Piezo buzzer
10k Variable Resistor
Breadboard 100x70
10 Kohm resistor
LM358 Op-amp IC
push button arduino
LDR 20mm
Wooden Box for enclosure
Zero PCB
High brightness LED red
7 Segment display (TM 1637)
Hardware & Tools
Soldering kit
Solder Flux, Rosin
Wire cutter
Digital Multimeter
Software & Tools
Arduino IDE
Project description
Code
Code for LASER Fire System
c
For count the number of times LASER Fire
1#include <Arduino.h> 2#include <TM1637Display.h> 3// Module connection pins (Digital Pins) 4#define CLK 9 5#define DIO 8 6TM1637Display display(CLK, DIO); 7 // the number of the pushbutton pin 8const int FireButton = 11; 9int Fire_State = 0; // variable for reading the pushbutton status 10int button_state=0; 11int k=0; 12const int Reset_Button=10; 13const int buzzer=13; 14const int LASER=12; 15void setup() { 16 pinMode(FireButton, OUTPUT); 17 pinMode(buzzer, OUTPUT); 18 pinMode(LASER, OUTPUT); 19 // initialize the pushbutton pin as an input: 20 pinMode(Reset_Button, INPUT); 21 Serial.begin(9600); 22 display.clear(); 23 display.setBrightness(0x0f); 24 display.showNumberDec(k, true); // Expect: 0000 25} 26void loop() 27{ 28display.setBrightness(0x0f); 29 // read the state of the pushbutton value: 30 Fire_State = digitalRead(FireButton); 31 button_state=digitalRead(Reset_Button); 32 //Serial.println(digitalRead(LASER)); 33 // check if the pushbutton is pressed. If it is, the Fire_State is HIGH: 34noTone(buzzer); 35digitalWrite(LASER, LOW); 36 if (Fire_State == HIGH) 37 { 38 display.showNumberDec(k, true); 39 tone(buzzer, 1000); 40 k=k+1; 41 digitalWrite(FireButton, HIGH); 42 digitalWrite(LASER, HIGH); 43 Serial.println(digitalRead(LASER)); 44 } 45 if (button_state ==HIGH) 46 { 47 k=0; 48 display.showNumberDec(k, true); // Expect: 0000 49 } 50 else { 51 digitalWrite(FireButton, LOW); 52 } 53 delay(100); 54}
Digital Target System (LDR)
c
File For Target
1#include <Arduino.h> 2#include <TM1637Display.h> 3// Module connection pins (Digital Pins) 4#define CLK 10 5#define DIO 9 6TM1637Display display(CLK, DIO); 7const int LDR_Pin = 6; // the number of the pushbutton pin 8const int ledPin = 13; // the number of the LED pin 9// variables will change: 10int LDR_State = 0; // variable for reading the pushbutton status 11int button_state=0; 12int k=0; 13const int BUTTONPIN=8; 14const int buzzer=5; 15void setup() { 16 // initialize the LED pin as an output: 17 pinMode(ledPin, OUTPUT); 18 pinMode(buzzer, OUTPUT); 19 // initialize the pushbutton pin as an input: 20 pinMode(LDR_Pin, INPUT); 21 pinMode(BUTTONPIN, INPUT); 22 Serial.begin(9200); 23 display.clear(); 24 display.setBrightness(0x0f); 25 display.showNumberDec(k, true); // Expect: 0000 26} 27void loop() 28{ 29display.setBrightness(0x0f); 30 // read the state of the pushbutton value: 31 LDR_State = digitalRead(LDR_Pin); 32 button_state=digitalRead(BUTTONPIN); 33 Serial.println(LDR_State); 34 // check if the pushbutton is pressed. If it is, the LDR_State is HIGH: 35noTone(buzzer); 36 if (LDR_State == HIGH) 37 { 38 display.showNumberDec(k, true); 39 tone(buzzer, 1000); 40 k=k+1; 41 digitalWrite(ledPin, HIGH); 42 } 43 if (button_state ==HIGH) 44 { 45 k=0; 46 display.showNumberDec(k, true); 47 } 48 else { 49 digitalWrite(ledPin, LOW); 50 } 51 delay(100); 52 }
Comments
Only logged in users can leave comments