int vpin = 3;
int Lightpin = 13;
int gndpin = A1;
void setup() {
pinMode (gndpin, LOW);
Serial . begin (9600);
}
void loop() {
int rawReading = analogRead (vpin);
int brightness = ((rawReading +.01)/20.80) /.01176;
analogWrite (Lightpin, brightness);
float volts = rawReading / 204.8;
Serial . println (rawReading
);
delay(20000);
}
Okay so for the code what you are seeing is the beginning of my code. the end goal is a keyboard with rgb light dimmed by a photo resistor right now im working on each individual step the kinda slapping it all together. the next step im thinking of doing is to do another analog read input for my key input.
rough sketch of what im doing. The idea hit that instead of some library that needs to be hooked up to the clock why not have it do input through variable resistance? Why some may ask well with just two separate resistors connected i have 3 options per pair: one resistor, parallel, series. with just 10 diffrent resistors i have 300 configurations(((10)^2)*3).
could the leonardo be used translate resistance values into key stroke? could this potentially reduce processing consumption versus the standard key library? is this something others feel would be worth pursuing?
one resistor, parallel, series. with just 10 diffrent resistors i have 300 configurations(((10)^2)*3).
No that is wrong. Not sure what you are trying to do but that makes little sense to me.
While your project is clear in your head it does not come over what you want to do.
Yes you can bet 256 keys read from the analogue port by converting the signal into analogue but that will only work for one key being pressed at one time and will require a lot of very precise resistors.
my math was that i have two places to place resistors, i calculated 10 separate resistor values (not yet defined) and three possible ways to wire the resistors all adding up to a different value;parallel 1/Rt = 1/R1 + 1/R2, Series RT = R1 + R2 and then one resistor R=R
there for the variables should be 10 possible resistors x 10 other possible resistors x 3 possible wire configurations is that wrong?
A resistor ladder of equal resistors is easier to construct and handle. The voltages from 256 resistors will fit neatly to an ADC, resulting in steps of 4 on the Arduino ADC.
I think you will have a better, more responsive system if you wire up a 16x16 keypad and use the keypad.h library to scan for button presses. It basically drives all columns high to start. Then one at a time, drives 1 column low, reads the rows to see if any are low from being connected to that column. Know the column, know the row = know the key.
Bring column back, read the next row.
Can continuously scan them all, or make it interrupt based - keep all columns low, when a low from a row press is seen use DIODE-AND to create an interrupt, bring all columns high and then scan the 16 rows.
Pretty sure that will be a lot faster than a whole bunch of analog reads at 100+uS/read.
Can use 32 IO pins for the scanning, or make it shift register based. Two 74HC595 serial-in parallel out for the outputs, two CD74HC597 parallel in/serial out for the inputs. Transfer in & out with SPI.transfer, just need 4 IO pins - SCK, MOSI, latch, MISO. Maybe 2 latches, but I think just 1 can do it.
Can still make with 16 diodes for a common interrupt.