The Vas
UNITED STATES OF AMERICA • + Follow
Edit Project
Description
ADC2PWM PCB
ADC2PWM
#include <Arduino.h>
#define PWM_PIN PB1
#define ADC_PIN 1 // PB2
void setup() {
// Set the PWM pin as output
DDRB |= _BV(PWM_PIN);
// Configure Timer/Counter0
TCCR0A = 0x00;
TCCR0A |= _BV(WGM00) | _BV(COM0A0)| _BV(COM0B1);
TCCR0B = 0x00;
TCCR0B |= _BV(CS02); // Set the PWM frequency to 122 Hz
TCNT0 = 0;
OCR0B = 0;
// ADC configuration
ADMUX = _BV(MUX0); // Select ADC input channel 1 (PB2)
ADCSRA = _BV(ADEN) | // Enable ADC
_BV(ADPS2) | // Set prescaler to 64 (125kHz with 8MHz clock)
_BV(ADPS1);
}
void loop() {
// Start ADC conversion
ADCSRA |= _BV(ADSC);
// Wait for conversion to complete
while (ADCSRA & _BV(ADSC));
// Read ADC value (10-bit value)
uint16_t adcValue = ADC;
// Scale ADC value to match OCR1A range (0 to OCR1C)
uint8_t pwmValue = adcValue >> 2;
OCR0B = pwmValue;
}
Nov 13,2024
23 views
ADC2PWM PCB
ADC2PWM
23
0
0
Published: Nov 13,2024
Download Gerber file 0
Purchase
Donation Received ($)
PCBWay Donate 10% cost To Author
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
Copy this HTML into your page to embed a link to order this shared project
Copy
Under the
Attribution-NonCommercial (CC BY-NC)
License.
Topic
- Comments(0)
- Likes(0)
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP
0 / 10000
Remove
It looks like you have not written anything. Please add a comment and try again.
View More
View More
VOTING
0 votes
- 0 USER VOTES
0.00
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Design
1/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Usability
2/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Creativity
3/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Content
4/4
More by The Vas
- ToFnLED v1 ToF sensor and RGB LED controlled via I2C bus are placed on a small board for use in espresso coffee...
- ADC2PWM PCB ADC2PWM#include <Arduino.h> #define PWM_PIN PB1 #define ADC_PIN 1 // PB2 void setup()...
- FPC scales cable adapter 5 pin JST adapter for Dual HX711 scales board with FPC connector
- GaggiaBoard_V2.1 GaggiaBoard_V2.1Gerber zip contains LCSC BOM and Centroid file
- Dual HX711 scales board with FPC connector Compact dual HX711 board for electronic scales with FPC connector.Gerber zip contains LCSC BOM and C...
- GaggiaBoard_V3 GaggiaBoard_V3Gerber zip contains LCSC BOM and Centroid fileWARNING!Most of SMD components are place...
- Dual HX711 scales board Compact dual HX711 board for electronic scales.Allows common or separate VCC and VDD, as well as com...
You may also like
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
64 0 0 -
-
-
-
Sega Master System RGB Encoder Switcher Z80 QSB v1.2
65 0 0 -
18650 2S2P Battery Charger, Protection and 5V Output Board
88 0 0 -
High Precision Thermal Imager + Infrared Thermometer | OpenTemp
456 0 7 -
Sony PlayStation Multi Output Frequency Oscillator (MOFO) v1
135 0 2 -