Devices & Components
Arduino Mega 2560 Rev3
10 jumper wires 150mm male
12 volt Adapter
PC fan
Mini breadboard - White
Hardware & Tools
Wire Stripper
Wire cutter
Software & Tools
Arduino IDE
Project description
Code
Code
cpp
Code of the project
1int icr, frecuency, duty_cycle; 2void setup() { 3 Serial.begin(9600); 4 pinMode(11, OUTPUT); 5 6 // Timer/Counter 1 initialization 7 TCCR1A = 0xA2; 8 TCCR1B = 0x19; 9 TCNT1H = 0x00; 10 TCNT1L = 0x00; 11 12 duty_cycle = 20; // Change this value to the desired duty cycle (0-100 %) 13 icr = 639; // icr and frecuency values are set to generate a 25 kHZ signal 14 frecuency = 16000000 / (1 + icr); 15 16 ICR1H = icr >> 8; 17 ICR1L = icr & 0x00ff; 18 // Sets the duty cycle with the value entered in line 12 19 OCR1A = icr * (duty_cycle / 100.0); 20} 21 22void loop() { 23 // Prints the current duty cycle on the serial monitor every second 24 Serial.print(" Duty cycle (%) = "); Serial.println(duty_cycle); 25 delay(1000); 26}
Documentation
Connections diagram / scheamtic
Diagrams that shows how things are connected
Connections_diagram.jpg

Comments
Only logged in users can leave comments