Simulation problem (force sensor)

Hello everyone,
I'm trying to simulate the code below as when pressing on force sensor 50 times the led light turns on. but when I work on tinker cad to simulate it it looks it doesn't work



int fsrPin = 0;     // the FSR and 10K pulldown are connected to a0
int fsrReading;     // the analog reading from the FSR resistor divider
int led = 13;
void setup(void) {
  pinMode (led, OUTPUT);
void loop(void) {
  fsrReading = analogRead(fsrPin);  
  Serial.print("Analog reading = ");
  Serial.print(fsrReading);     // print the raw analog reading
  int Counter = 0;
  if (fsrReading >0) {
if (Counter=50){
 digitalWrite (led,HIGH);
 digitalWrite (led,LOW);


shouldn't Counter be global so that it's value is persistent between calls to loop()?

  int Counter = 0;

Every time through loop() this sets Counter to zero

    if (Counter = 50)

Sets Counter to 50 rather than comparing Counter to 50

but I want Counter to be compared so when pressing the 50 press it turns.
didn't got your point.

int Counter = 0;

how can I fix it?

what do you mean sir?

You were told in your other topic with this code.

fsrReading does not need global scope, but Counter does

1 Like

I already fixed them sir but but I face problem in simulating it.

If you'd fixed them, we wouldn't be here.

where should I go?

You didn't fix that either.

Why are we discussing the same code across two topics?

Sorry but I didn't get your point what should I fix in this

if (Counter=50){

50 is non-zero.
Assigning it to a variable makes the expression non-zero, therefore always true.

I suspect you want ==

This was highlighted in your other topic

Not any more we aren't

The duplicate topic has been deleted

@ibrahimalzoubi why did you start another topic on the same subject ?

I can't find the previous topic.

This is the "previous" topic and you appear to have found it

thx. I'm new in this platform sorry for the innconvieniance.