Ardunio Uno R3 & LCD & FSR

Hi,
I am trying to pull together Uno R3 a 16*2 LCD Display and a FSR sensor through a breadboard. I'll read Force with FSR and based on examples categorize the output than display on the LCD the result text. My input source is the Mac that I also run IDE and read debug.

LCD is working, I had successfully test FSR without LCD integrated. When all is combined A0 analog port (I tried other ports and even with a timer, e.i capacitor, digital port) event FSR sensor is not connected , software continuously read fluctuating values. I have read forums entries and some internet content, common ground is advised but I already use the +- of the same breadboard. Could anyone have a suggestion?
Code:

// include the library code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int fsrAnalogPin = A0;
int fsrReading;
int fsrDigitalPin = 8;
int fsrDigitalReading;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);  // We'll send debugging information via the Serial monitor
  Serial.print("Setup ");
  analogReference(INTERNAL);
  //pinMode(fsrAnalogPin, INPUT) ;
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Basi Kuvveti=");
}

void loop() {
  // put your main code here, to run repeatedly:
  fsrReading = analogRead(fsrAnalogPin);
  // read the resistor using the RCtime technique
  //fsrDigitalReading = RCtime(fsrDigitalPin);

  //if (fsrDigitalReading == 30000) {
  // if we got 30000 that means we 'timed out'
  //  Serial.println("Nothing connected!");
  //} else {
  //  Serial.print("RCtime reading = ");
  //  Serial.println(fsrDigitalReading);     // the raw analog reading

  //}
  //float voltage_A2 = fsrReading * (5 / 1023.0);
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
  //Serial.print(" ");
  //Serial.println(voltage_A2);

  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  //lcd.print(millis() / 1000);
  //lcd.print(" ");
  // We'll have a few threshholds, qualitatively determined
  Serial.println(fsrReading);
  if (fsrReading < 10) {
    lcd.print("Basi yok      ");
  } else if (fsrReading < 200) {
    lcd.print("Hafif dokunus ");
  } else if (fsrReading < 500) {
    lcd.print("Hafif basi    ");
  } else if (fsrReading < 800) {
    lcd.print("Orta basi     ");
  } else {
    lcd.print("Kuvvetli sikma");
  }


  delay(1000);
}

// Uses a digital pin to measure a resistor (like an FSR or photocell!)
// We do this by having the resistor feed current into a capacitor and
// counting how long it takes to get to Vcc/2 (for most arduinos, thats 2.5V)
int RCtime(int RCpin) {
  int reading = 0;  // start with 0

  // set the pin to an output and pull to LOW (ground)
  pinMode(RCpin, OUTPUT);
  digitalWrite(RCpin, LOW);

  // Now set the pin to an input and...
  pinMode(RCpin, INPUT);
  while (digitalRead(RCpin) == LOW) {  // count how long it takes to rise up to HIGH
    reading++;                         // increment to keep track of time

    if (reading == 30000) {
      // if we got this far, the resistance is so high
      // its likely that nothing is connected!
      break;  // leave the loop
    }
  }
  // OK either we maxed out at 30000 or hopefully got a reading, return the count

  return reading;
}

I hava also tried using a 3.3V pin rather than 5V to reduce current or lower the brightness of LED but these did not help. I thought of making a safe grounding but since it is DC that might not seem to help. I change the power supply from computer to and adapter that didn't also help.

Any help would be appreciated!

Using the same + on a circuit is not the same as a common ground.

Code without a schematic is only telling us half the story.
A photograph of a tangle of wires is not going to tell us what we need to know to make a meaningful answer.

Note that your bread board has gaps in the graphic of lines for the busses. That means there is a break in continuity of the circuit. These need to be bridged with wires to make the bus lines work like you are expecting them to work.

1 Like

Legend! Mind the gap :rofl: "your bread board has gaps in the graphic of lines for the busses". Interesting that positive travels horizontal axis of top most two rows but ground not. I made inter gap ground cabling on breadboard just for grounding and it did it. Today I was to go for shopping for a avometer and isolated stand alone power supply. You save my day! Really appreciated. Best.

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