2 analog values to one digital pin

Hello I am new to arduino programming
How can I get 2 analog values to one digital pin

What I want to do is make a h shifter with 2 potentiometer if A1 is 0 to 100 a and A2 150 to 200 that would make one digital output

I know I can make the shifter with switches but I don't what too

If you can ride a example code
THANKS

Perhaps if you explain that, perhaps with a diagram, we will understand better what you want to achieve.

a1Value = analogRead(A1);
a2Value = analogRead(A2);
if (a1Value > = 0 && a1Value <= 100 && a2Value >= 150 && a2Value <=200)
{
  diagitalWrite(digitalPin, HIGH);
} 

Is that the sort of thing you mean ?

Yes it is I will try this maybe I will have more questions
THANKS

Hello Rudywiens
Take a view here.

Have a nice day and enjoy coding in C++.

#include "UnoJoy.h"

void setup(){
setupPins();
setupUnoJoy();
}

void loop(){
// Always be getting fresh data
dataForController_t controllerData = getControllerData();
setControllerData(controllerData);
}

void setupPins(void){
// Set all the digital pins as inputs
// with the pull-up enabled, except for the
// two serial line pins
for (int i = 2; i <= 12; i++){
pinMode(i, INPUT);
digitalWrite(i, HIGH);
}
pinMode(A4, INPUT);
digitalWrite(A4, HIGH);
pinMode(A5, INPUT);
digitalWrite(A5, HIGH);
}

dataForController_t getControllerData(void){

// Set up a place for our controller data
// Use the getBlankDataForController() function, since
// just declaring a fresh dataForController_t tends
// to get you one filled with junk from other, random
// values that were in those memory locations before
dataForController_t controllerData = getBlankDataForController();
// Since our buttons are all held high and
// pulled low when pressed, we use the "!"
// operator to invert the readings from the pins
controllerData.triangleOn = !digitalRead(2);
controllerData.circleOn = !digitalRead(3);
controllerData.squareOn = !digitalRead(4);
controllerData.crossOn = !digitalRead(5);
controllerData.dpadUpOn = !digitalRead(6);
controllerData.dpadDownOn = !digitalRead(7);
controllerData.dpadLeftOn = !digitalRead(8);
controllerData.dpadRightOn = !digitalRead(9);
controllerData.l1On = !digitalRead(10);
controllerData.r1On = !digitalRead(11);
controllerData.selectOn = !digitalRead(12);
controllerData.startOn = !digitalRead(A4);
controllerData.homeOn = !digitalRead(A5);

int analogPin = A0; //analog input 0
int analogPin1 = A1; // analog input 1

int val0 = 0; // variable to store the value read of a0
int val1 = 0; // variable to store the value read of a1
int ledPin = 13; // LED connected to digital pin 13

// Set the analog sticks
// Since analogRead(pin) returns a 10 bit value,
// we need to perform a bit shift operation to
// lose the 2 least significant bits and get an
// 8 bit number that we can use
controllerData.leftStickX = analogRead(A0) >> 2;
controllerData.leftStickY = analogRead(A1) >> 2;
controllerData.rightStickX = analogRead(A2) >> 2;
val0 = analogRead(analogPin); // read the input a0 pin
if (val0 > 200)
{
controllerData.triangleOn = !digitalRead(2);
}
// And return the data!
return controllerData;
}

i have this code i want to controllerData.triangleOn = !digitalRead(2); to be a button in 360 emulator

@Rudywiens

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

When you posted your code without code tags did you receive a warning message ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.