[ Log In ]
10K timmer potentiometer

10K Trimmer Potentiometer (Through Hole)

$0.85
Qty:
20k trimmer potentiometer

20K Through Hole Trimmer Potentiometer

$0.85
Qty:
Top view of 50k Trimmer variable resistor potentiometer

50K Trimmer Through Hole

$0.85
Qty:
Flex Sensor - Sensing Bending and Displacement

55.37mm (2.18 Inch) Flex Sensor

$8.50
Qty:
USB 2.0 Cable 10 Foot Type A Male to Type B Male

USB 2.0 Cable Type A Male to Type B Male - 10 FT

$4.80
Qty:
Multimeter Security Banana Plug To Test Hook Clip Probe Lead Cable 500V

Multimeter Security Banana Plug To Test Hook Clip Probe Lead Cable 500V

$8.99
Qty:
3 Foot USB Cable Type A to USB Cable Type A

USB Cable Type A Male to USB Type A Male - 3 FT

$2.65
Qty:
Tumbnail: 62 oz-in NEMA 17 Stepping motors (also called stepper motor)

NEMA 17 Stepping Motor (62 oz-in 5mm single shaft)

$19.95 Out of Stock
Qty:
Image of the Atmega324p

Atmega324P

$8.50
Qty:

Programming: ADC (Analog to Digital Converter) Establishing Multiple ADC Channels for Two Trimmers

Two trimmers are connected to the ADC one on channel 1 and the other on channel 2. The pressure sensor is connected to channel 0.

The two trimmers will be adjusting a low threshold and a high threshold for the pressure sensor and pin output function.
#include <avr/io.h>
#include "MrLCD.h"
#include <avr/interrupt.h>

int static volatile InchesOfHg, High, Low = 0;

int main(void)
{
InitializeMrLCD();
Send_A_StringToMrLCDWithLocation(1, 1, "Inches of Hg:");
Send_A_StringToMrLCDWithLocation(1, 2, "H: L:");

DDRD |= 1<<PIND0;

ADCSRA |= 1<<ADPS2;
ADMUX |= 1<<REFS0;
ADCSRA |= 1<<ADIE;
ADCSRA |= 1<<ADEN;

sei();

ADCSRA |= 1<<ADSC;

uint8_t enoughVacuum = 0;

while (1)
{
if (InchesOfHg > High) enoughVacuum = 1;
if (InchesOfHg < Low) enoughVacuum = 0;

if (enoughVacuum == 0 && bit_is_clear(PORTD, PIND0)) PORTD |= 1<<PIND0;
if (enoughVacuum == 1 && bit_is_set(PORTD, PIND0)) PORTD &= ~(1<<PIND0);
}
}
ISR(ADC_vect)
{
uint8_t theLowADC = ADCL;
uint16_t TenBitResult = ADCH<<8 | theLowADC;

switch (ADMUX)
{
case 0x40:
InchesOfHg = -0.0376 * TenBitResult + 35.532;
Send_An_IntegerToMrLCD(15, 1, InchesOfHg, 4);
ADMUX = 0x41;
break;
case 0x41:
High = .034 * TenBitResult -.68;
Send_An_IntegerToMrLCD(4, 2, High, 3);
ADMUX = 0x42;
break;
case 0x42:
Low = .034 * TenBitResult -.68;
Send_An_IntegerToMrLCD(14, 2, Low, 3);
ADMUX = 0x40;
break;
default:
//Default code
break;
}

ADCSRA |= 1<<ADSC;
}

Comments and Additional Information

Have some code to share? Or additional information? Respond here:

You need to be logged in to save a response on this page. The response must be constructive, helpful, supplimentary or to correct the existing video, code or narrative content.

Description:

Code (optional):