I am very new to micro-processors and programming in general, but I am pretty good with discrete electronics but I am by no means an expert.
I want to start some threads that will help very base level beginners like myself understand some basic concepts.
My question for today is, how do I compare bits for say, direction control of motors?
I understand that if I had an analog input (0-3.3V) it gets converted to a 10 bit integer, 0-1023, assuming that I haven't changed the range.
Can you more experienced people help me fill in my pseudo code?
public static void Main() { InputPort Xaxis = new InputPort(pins.analogPinA1); // Defining the analog input port as my joystick axis OutputPort Direction1 = new OutputPort(pins.outputpin1); // Defining the output port to a motor driver direction 1 enable OutputPort Direction2 = new OutputPort(pins.outputpin2); // Defining the output port to a motor driver direction 2 enable //I have made the range for directions 0-1023, with a 128bit "dead zone" For(Xaxis > 576bits) { Direction1.value = true; //this gives me direction forward } For(Xaxis < 448bits) { Direction2.value = true; //this gives me direction reverse } }