Go Down

Topic: 4 DIGIT 12V 7 SEGMENT DISPLAY (Read 12591 times) previous topic - next topic

megappeh

hai PaulRb....sorry I tried your code ,if i want to add ir beam, how to create code for ir beam ? because I tried did not work . I am confused..tanks

PaulRB

hai PaulRb....sorry I tried your code ,if i want to add ir beam, how to create code for ir beam ? because I tried did not work . I am confused..tanks
I am confused also. The last time i gave you some code was months ago.

Did you get it working? If not, describe what happens and what you want to happen.

Also post the code you are working on.

megappeh

this your code paul...i want add ir beam
for counter up....i try but not work...tanks
const byte pattern[10] = {
  //ABCDEFGX
  0b11111100, //0
  0b01100000, //1
  0b11011010, //2
  0b11110010, //3
  0b01100110, //4
  0b10110110, //5
  0b10111110, //6
  0b11100000, //7
  0b11111110, //8
  0b11100110  //9
};

const int latchPin = 12;
const int clockPin = 13;
const int dataPin = 2;
const int Button = A0;
const int buttonThreshold = 500;
int lastButton = 1023;
unsigned long lastPressed;
int num;

void setup() {

  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(Button, INPUT);

  Serial.begin(9600);
}

void loop() {

  int buttonNow = analogRead (Button);
  unsigned long timeNow = millis();

  if (buttonNow <= buttonThreshold && lastButton > buttonThreshold && timeNow - lastPressed > 50) {
    if (++num > 999) num = 0;
    lastPressed = timeNow;
  }
  lastButton = buttonNow;

  digitalWrite(latchPin, 0);

  int numCopy = num;
  for (int d = 0; d < 3; d++) {
    shiftOut(dataPin, clockPin, MSBFIRST, pattern [numCopy % 10]);
    numCopy /= 10;
  }
 
  digitalWrite(latchPin, 1);
  delay (500);

}

PaulRB

Look like you forgot how to post code!

megappeh

#79
May 17, 2016, 02:35 am Last Edit: May 17, 2016, 02:51 am by megappeh
Code: [Select]

[/
const byte pattern[10] = {
  //ABCDEFGX
  0b11111100, //0
  0b01100000, //1
  0b11011010, //2
  0b11110010, //3
  0b01100110, //4
  0b10110110, //5
  0b10111110, //6
  0b11100000, //7
  0b11111110, //8
  0b11100110  //9
};

const int latchPin = 12;
const int clockPin = 13;
const int dataPin = 2;
const int Button = A0;
const int sensor=A1
const int buttonThreshold = 500;
int lastButton = 1023;
unsigned long lastPressed;
int num;

void setup() {

  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(Button, INPUT);
pinMode(sensor,INPUT)
  Serial.begin(9600);
}

void loop() {

  int buttonNow = analogRead (Button);
  unsigned long timeNow = millis();

int sensorNow = analogRead (sensor);
  unsigned long timeNow = millis();
  if (butonNow <= buttonThreshold && lastbutton > buttonThreshold && timeNow - lastpressed> 50) {
    if (++num > 999) num = 0;
    lastpressed= timeNow;
  }
  lastButton = buttonNow;

  digitalWrite(latchPin, 0);

if (sensorNow <= sensorThreshold && lastsensor> sensorThreshold && timeNow - lastpressed> 50) {
    if (++num > 999) num = 0;
    lastpressed= timeNow;
  }
  lastsensor = sensorNow;

  digitalWrite(latchPin, 0);
  int numCopy = num;
  for (int d = 0; d < 3; d++) {
    shiftOut(dataPin, clockPin, MSBFIRST, pattern [numCopy % 10]);
    numCopy /= 10;
  }
 
  digitalWrite(latchPin, 1);
  delay (500);

} ]

PaulRB

#80
May 17, 2016, 07:39 am Last Edit: May 17, 2016, 07:42 am by PaulRB
Ok, the code in your latest post is still corrupt. Re-post it from the IDE. Please do not waste our time posting another corrupt version.

because I tried did not work
If you want help on this or any forum, never say that. It does not give any useful information and that means no-one can help you. You must learn to explain what is wrong, precicely what happens when you try and precicely what you want to happen. This ability is an important life skill, not just an Arduino skill.

Reading the corrupt version of your code that you posted incorrectly, i suspect that even the un-corrupted version will not compile. Am i correct? What errors do you see? Post the error messages using code tags.

megappeh

tanks paulrb..
i just change button with sensor (ir beam)
but ir beam not work.i use ir beam for counter up..

if (sensorNow <= sensorThreshold && lastsensor> sensorThreshold && timeNow - lastpressed> 50) {
    if (++num > 999) num = 0;
    lastpressed= timeNow;
  }
  lastsensor = sensorNow;

  digitalWrite(latchPin, 0);

AWOL

Quote
ir beam not work
Please re-read reply #80

PaulRB

I don't think megappeh can understand my English, but is too embarrassed to admit it. This is my fault, I am not writing plainly enough.

Go Up