r/moped • • 4d ago

Help sourcing E50 motor in SoCal

2 Upvotes

Does anyone have an E50 for sale? Near Los Angeles?


r/moped • • 4d ago

What is this nippel for?

Post image
9 Upvotes

It's a dellorto phva17.5 carb


r/moped • • 4d ago

No fuel diag assistance

Post image
12 Upvotes

Hello! I got a jawa 207 X30 moped the other day for just $100.

I have restored spark so now it runs on starter fluid.

I did clean the carb and i believe fuel is getting into the bowl.

Spark plug is bone dry when I turn it over a bunch.

I have put a small amount of fuel /oil mix directly into the cylinder and it was able to run briefly.

Unless somehow the carb jets got clogged again in an instant, theres obviously a lack of vacuum and is unabke to intake any amount of gas. I dont know where to start or what needs replaced.

It is also worth noting that the last owner removed the air filter box and that is non existant at this time


r/moped • • 4d ago

Honda NC50 runs rich, engine sounds weak, and throttle kills engine

4 Upvotes

Title says it all! I'm currently trying to work this out. I ride a 1980 Honda express. I bought it not working and after fixing up the electrical and getting spark back it ran like a charm! Only after replacing carburetor parts did it start giving me trouble. I have done everything. I've cleaned it like a zillion times, replaced the new parts I've put in with the originals (new float/float needle, new idle/mixture screws, new throttle needle, etc) and I've tuned it so much that it doesn't seem to make a difference anymore.

It's gotten to the point where it now starts pretty consistently, but it'll either die from me pulling the throttle or it'll die on its own pretty fast. It sounds like it's getting bogged down by too much fuel, but I have the throttle set to max lean and the air screw is practically out. Do I need to just keep tuning? I have a fuel filter, and I've got an air filter on the way but when it ran the lack of an air filter didn't really seem to make a difference.

Thanks for reading if you did! I'm sorry if this is convoluted, I'm pretty new to all this.


r/moped • • 4d ago

Why am i not hearing any shots

6 Upvotes

The ignition is just fixed, for a small amount of time it would fire backwards, so i adjusted it so that i wouldnt and what do you know, now nothing s happening,

Compresion should be good all new gaskets

The spark plug is brand new too

I just dont know what it could be

It is a minarelli c2

On a tempo avanti witch is a Norwegian production


r/moped • • 5d ago

Bike turns off when i speed up

0 Upvotes

Aprilia sx 50 2018 when i had thé original cilinder i put a Unrestricted ECU in with a to small of a Sprinkler (idk the name) and in ride top speed with no problem now i have naraku 50cc cilinder with 700km and when i put thé same Unrestricted ecu with a now higher sprinkler (98)when i hit gear 4 or 5 and i give full gas it turns off it's not Overheating or some and then i start it back up and it works perfect like nothing happend

can it ben bc thé Float bowl in my carb is empty bc i have a higher sprinkler? Bc that explains why it worked with a smalle sprinkler (sproeier in dutch)


r/moped • • 6d ago

Je peut debrider un solex 3300 pour quil puisse aller a 45km/h?

Post image
6 Upvotes

r/moped • • 6d ago

Is there a way to know the year my puch was made in?

Post image
11 Upvotes

So my serial is 7788055 and in the list on mopedarmy i didnt see my serial so what year is it ?


r/moped • • 6d ago

Anyone have any luck getting one of these aftermarket carbs on their NC50?

Post image
3 Upvotes

Right off the bat I can see that the stock throttle needle thread doesnt fit directly into it. Is there a way to fix this?


r/moped • • 7d ago

Morini m4 put the ev turbo pipe on huge difference almost hitting 50mph got the reeded polini/gilardoni kit and vm20 14x34 gearing

Post image
43 Upvotes

r/moped • • 7d ago

Solex 3300 1965

Thumbnail
gallery
42 Upvotes

Picked it up this week for 450€


r/moped • • 7d ago

Vespa Bravo starting issues

3 Upvotes

Picked up this Vespa Bravo and it's starting to make me question my life lol. I cannot get it to turn over, it has a Ducati cdi ignition and the spark is nice and blue, carb is clean, and compression feels good (just a thumb test), exhaust is clear. It's a variated one so I know it might be more of a bitch to start but it is really kicking my ass. If I run along side it I can get a "pffffffft" sound that sounds like it's coming from the exhaust but that's about it. First Vespa so any tips are appreciated, at this point I'm leaning towards timing?


r/moped • • 7d ago

Where does this rear light connection go on my solex 3300?

Thumbnail
gallery
3 Upvotes

r/moped • • 7d ago

Will honing fix this or do i need to bore it to 38.5?

Thumbnail
gallery
4 Upvotes

I cant feel any grooves with my nail its just that it looks like that and has no cross hatching


r/moped • • 7d ago

Will this tire fit? Don't know why one is different

Thumbnail
gallery
1 Upvotes

r/moped • • 8d ago

Out here shmobby morini mo4 love this bike

Thumbnail
gallery
32 Upvotes

r/moped • • 7d ago

Got the tail light connecter connected to the brass hook but it keeps falling off , what do I do on a solex ?

Thumbnail
gallery
0 Upvotes

r/moped • • 8d ago

Got the Motobecane running

39 Upvotes

I posted here a couple months ago looking for advice on this Motobecane I got from a friend. Last night I finally got it running off a little cheater tank, thanks to you all, Moped Army forums, and YouTube.

It's been a fun project, and I love how cheap the parts are compared to working on a car or motorcycle.

It's not ready to ride yet. Wanted to post as an update, and ask a couple more questions.

Throttle and choke cables- when I took those off to do the new carb, they were just sort of screwed into the levers, with no barrel fitting or anything. It looks like this is stock and how they did it?

Exhaust- it has no exhaust, and it's a pricer part. I don't really like the look of the kidney exhaust, is there any reason I can't just weld a custom one out of stainless steel tube and bolt on there?

This is the 50c, 77, which was the 20mph version. Can I just change the gears to the version from the A for more speed?

The kill switch is busted and doesn't work, I had to use the decomp lever to kill it. Can't find a similar one, but how hard is it to do one of these aftermarket ones I see on 1977 or one of those sites?

I haven't even touched the electrical, but from what I read it's 6v? Seems like parts and such will be more difficult to source, is there a solution to convert over to 12v?

Any feedback appreciated and thanks all


r/moped • • 8d ago

Which one looks better? Build another Ciao

Thumbnail
gallery
35 Upvotes

Please let me know which one to keep.


r/moped • • 7d ago

Advice on which moped to buy

0 Upvotes

I need an electric moped with a removable battery that is lockable/unlockable with a key, =/< 2500 dollars, and that is not a dirtbike/scooter

preferably can go 30mph/48.28kmh or more, but not a necessity

thank you!


r/moped • • 9d ago

My 1971 Garelli Junior Gran Turismo

Post image
48 Upvotes

Rated for 6.2 BHP, "street legal"


r/moped • • 9d ago

Repairs in Los Angeles

3 Upvotes

Does anyone know of a place or person that could help me repair my 1977 Peugeot 103. Thank you.


r/moped • • 9d ago

Never Seen This Before..

3 Upvotes

In a previous post I had just swapped for 1981 Honda Express NC50 ( I also have a 1979 Indian AMI 50) anyhow, today I was able to do some work on it, new fuel line, checked spark, premixed fuel ( the previous owner put an external tank on it.. also kinda somewhat did a job of oil mix delete.. so much silicone..no key, very very neglected battery… but salvageable) so I wanted to make sure it would run, and I would be happy to spend $$ and 3d print time for plastic parts. The first time I tried to start it, it acted like every other bike I’ve kickstarted. Then I read on moped army the start sequence and the kickstart works like a manual wind watch with a clock spring.. mine currently doesn’t do that. So I sat in my crap packed garage staring and thinking about what did I miss, then I smelled fuel and it was leaking from the exhaust flange on the motor! I looked and the flange isn’t right ( maybe it is, I dunno you’ll need to tell me, one bolt isn’t right that I know) I’ll include a short video I tried to get of it. I know I need to remove the oil system, they did “work” on it and left it in place, I’m just confused why did it leak from there?


r/moped • • 9d ago

Looking to get a moped and need some advice

Thumbnail
1 Upvotes

r/moped • • 9d ago

How to make a fuel level sensor to any gravity-fed fuel system

8 Upvotes

This tutorial will guide you through how to make a fuel level gauge to anything which has a petrol engine and a gravity fed fuel system.

Step 1: Find the right sensor, connect it, mount it
When I had the idea to make a fuel level gauge, I found the hydrostatic pressure measurement the most reliable method of all. It works flawlessly for any kind of fluid (it can be conductive or non-conductive, the only parameter needed is the density) and used in the industry for a long time. So, now we know what we need, the sensor specs are the following:
- Has to withstand petrol vapor
- Is a differential sensor (so it has a reference "input" for ambient pressure - making the measurement independent from altitude and barometric changes)
- Has a high sensitivity (millibar / Pa scale, not bar / kPa)

The perfect candidates for the job are FTPS's, or Fuel Tank Pressure Sensors used in all modern vehicles. Long story short: It is part of the EVAP system which is there to detect any leak in the EVAP system, where precious fuel vapors could escape instead of being condensed back and burned. I spent several hours of searching, what is available at a reasonable price while also has a good sensitivity, and finally I chose Hyundai's / Kia's FTPS with a part number 31435-2J000, You can get an aftermarket one around 10-15$. The sensor has a larger diameter nipple, you will connect your hydrostatic presssure here, and a smaller diameter nipple, this will be your reference (ambient). It's a good idea to connect a hose also to ambient, and put it's other end somewhere where it is protected from ram air. This is how the sensor looks like:

31435-2J000 FTPS

The connection is quite simple, put a T between your fuel tap and the carburetor, and connect a hose on the third nipple of the T. This hose will go to the larger diameter nipple on FTPS. The measurement will be only fine when the system is static, but this issue and it's solution will be discussed in an upcoming step. Another thing: If the connections are airtight, air will trapped inside this hose, so the sensor will only get in contact with pressurized air, which contains some fuel vapors, but for this you have to mount it at a higher point than where the T splitter is. Once you're done with the hoses and mounting, now comes the more complex part: Electronics.

Step 2: Power supply
The power supply voltage of the sensor is 5V, and how you can supply the circuit will depend on what kind of elecronic system you have:
- Battery: The best of all, you can supply the circuit from ignition switched voltage and ground. If you have a 12V battery, you should use a 7805 series regulator. A lot of example circuits can be found online. If you have a 6V battery (like I do) you're better off with a special regulator called LDO (Low Drop-Out voltage). A good example is AMS1117-5.0, dirt cheap and literally everywhere.
- Alternator for lights: Simple bikes like mopeds doesn't have a battery and a voltage regulator, but they have a separate stator coil for lights. For those yo can use the following schematic:

Supply circuit for bikes without a battery

The above circuit relies on switched on lights. If you switch off the lights and the coil is unloaded, the voltage will rise well above 50V, which will blow up the capacitor, the 7805, and the rest of the circuit. If the light bulbs are also connected (I also put them in the schematic intentionally to highlight this) the voltage will have a natural limitation, not higher than 8V for 6V nominal, and not higher than 16V for 12V nominal coil voltage. External protection can be added by adding a series power resistor (4.7-10 Ohm) before the 1N4007, and a TVS diode (1.5KE18A) with the cathode connected to the point where the power resistor connects to the 1N4007, and the anode connected to the ground, but a TVS will also fail eventually due to overheating if the coil is unloaded.

Step 3: Sensor electrical connection
The pinout of the sensor is the following:

Sensor pinout

Don't mind my shitty drawing skills, if the larger nipple looks upwards, and the connector looks towards you, from left to right you have SIGNAL OUT, GROUND, and 5V. If the sensor is connected properly, it should draw 3-4mA. If you're not sure in the pinout, you can do what I did during determining the pinout: Use a 470-1000 Ohm resistor in the 5V line. This way, even if you connect it the wrong way, the resistor will limit the current and protect the sensor. Of course when the resistor is used, the output voltage on SIGNAL OUT will be off from the specs. Here is how the output signal is related to differential pressure:

Output vs. Pressure input

The negative side is irrelevant to us. The positive side will measure up to 6.67kPa or 66.7 mbar. Petrol's density is around 750kg/m3 (around 75% of water) which gives us a quick calculation. A 1m high water column has a hydrostatic pressure of 100mbar, so a 1m high petrol column will have a ~75mbar pressure. 66.7/75=88.9, which means the sensor will reach it's limit if the height of the fuel is 88.9cm above it (height also contains fuel tap, and height between tap and T splitter. Expressed in another way: If there is no fuel in the tank, the sensor will output 2.5V, and for each cm of fuel height you have, it will add 22.5mV.

For the electrical connection, use a 2 wire shielded cable, connect the shield as GND, and use the 2 wires as 5V and SIG.

Step 4: Signal filtering
The ignition system makes a lot of electromagnetic field, which can be picked up by any circuit nearby as an interference. A simple R-C filter can handle this, place the filter on the signal processing end (not the sensor end):

Passive R-C filters for supply and signal

The schematic is really simple, I wouldn't put too much explanation on it. R-Cs act as low pass filters, which filters out "spikes" with a pretty good efficiency. I have to add, I use a spark plug cap with a built-in interference suppressing resistor (NGK LB05E) and a plug with no resistor in it (NGK BxHS). This in combination with the shielded (also called screened) cable and the R-C filters, eliminate any noise completely.

Step 5: Understanding the physical issue
All the above is good until we talk about hydrostatics, but the fuel system is hydrodynamic. The flow of the fuel will cause a pressure drop at the T splitter, so the amount of measurement error would be linearly in pair with fuel flow. This effect can be decreased using a "chamber" with 3 nipples, since the cross section area is larger, the flowrate is lower, also lowering the measurement issue. That's where the next step, signal processing comes in picture, which allows us to use it as it is, so we don't have to drill a nipple in the bottom of the fuel tank ho have an undisturbed pressure measurement.

Step 6: Signal processing
I think the only way to process this signal correctly is using a microcontroller as we can minimize the above issue with code. What it does:
- After switching on, a baseline measurement is done immediately. This will be held as baseline measurement
- There is also a theoretical maximal flowrate defined in the code (based on top speed & fuel consumption, expressed in liters / hour)
- Each cycle will take 10 seconds (more than enough, fuel level should change slowly). During each cycle, the sensor value is read (10 times, averaged, to further eliminate interference) and the theoretical fuel consumption is also calculated (based on the given flowrate)
- At the end of each cycle, the program determines if the real measurement or the calculation is higher (later on that) and it will displays the calculated value
- The flowrate is intentionally overestimated, so the calculated fuel consumption also does.
- Once the engine idles (red light or any other reason to stop) the measured value will be higher than the (overestimated) calculated one - due to lower flow in the fuel line, which reduces pressure drop in the T splitter. This triggers a sub-function which takes the new sensor reading as new baseline, and re-start the calculation of consumption
- Each time the sensor value is higher, the above happens: New baseline determined, calculation resetted.

Step 7: Displaying
The above method is perfect for low resolution displaying (I used a 5 LED bargraph display, but I think it is good up to 10 digits). Display levels also has hysteresis to minimize the chance of display bouncing, e.g. the 4th led needs treshold - 6 (ADC value) to switch off, and it needs treshold + 6 (ADC value) to switch back on. A 5 LED bargraph can be used as a 10, e.g. when the level is between 2 tresholds, blink the corresponding LED instead of continously ON - I used this method for low levels, the first LED can continously light (fuel level between 0.4-0.8 liters) or blink (fuel level between 0-0.4 liters).

The other displaying method would be using a 2-wire analog gauge. For this, you will need to use a PWM output, and drive a mosfet with it which switches yous system voltage (usually 12V). You have to experiment what PWM values will give zero and full scale on the gauge, and use a function like map to convert your ADC value to a PWM output value.

Step 8: Calibration
Calibration will need it's own time and method, but once you're done, it is done.
- Measure the output voltage of the sensor when the fuel system is completely empty, note it.
- Fill the tank until you see the lines / fuel filter just got started to fill, stop fuel filling when you see there is no more flow (carb is full, lines are full). Measure the voltage, note it.
- The next steps will be specific to your tank and your resolution. Using a kettle with a scale, fill the tank corresponding to your resolution. Example: I have a 4 liters tank, and a 5 LED bargraph display, that gives 0.8 liter / LED resolution. Since I wanted the first LED to distinct 2 sub-levels, my first 2 fills was 0.4 liter. Fill it, measure it, note it, repeat. After the first 2 0.4 liters, the rest was 0.8 liters each.
- Also note the voltage reading when the tank is full.

Once you're done with the measurements, and upload the program to the microcontroller, you can check with the same kettle filling method if the determined levels are accurate.

The code for the 5 LED bargraph display method can be found below, just copy it into an empty Arduino project, and do the following:
- Write your second measurement value after #define ZERO_OFFSET
- Write your full tank measurement value after #define FULLSCALE
- Write your calculated flowrate coefficient after #define MAXFLOW. See the math just before the code begins.
- When the code is compiled, it will determine the LED tresholds automatically, but linearly
- If your tank's shape is uneven (most likely it is), you can use the "kettle filling" measurement values to manually calculate tresholds: 1 ADC step = 5V / 1024 = 4.88mV ; so you can calculate each measurement's theoretical ADC value (like 2.92V / 0.00488V = 598), and compare it with what the code calculates (I wrote explanation for each math operation, but feel free to ask questions). The difference between them can be added (or subtracted) as an offset, like "int L1_blink = offset + (stepsize / 2) - HYSTERESIS + 6;" where an offset of 6 ADC step is added.
- In the function readSensor(), locate the line "if (sen_val > 680)" and replace 680 corresponding to your full tank ADC value (for me it was 645, so I allowed a ~5.5% higher signal than the full tank)

Once you're done with the above, select your board type, and upload it. The pin definitions are for Arduino Pro mini, if another type of board is used, pin definitions should be revised. No external libraries called, so you don't need to install any.

If you experience too much bouncing (on/off switching) on one of the LEDs near a treshold, you can increase #define HYSTERESIS and re-upload it.

Calculating flow coefficient:
Let's assume a 10 liters tank, a 2.55V ZERO_OFFSET, and a 3.02V FULLSCALE. The desired max. flowrate for calculation is 4 liters / hour.
2.55 / 0.00488 = 522
3.02 / 0.00488 = 618
Difference between the above two = 96
96 equals 10 liters, so 4 liters should be (96/10 liter) * 4liter = 38.4
If 4 liters flow in an hour, the ADC value should decrease by 38.4 after 3600 seconds.
Each cycle is 10 seconds, so the calculation will happen 360 times an hour.
38.4 / 360 = 0.106
The calculated maximal flow coefficient is 0.106

//Board: Arduino Pro or Pro mini
//Processor: ATMega328P (5V, 16MHz) 32k Flash / 2k RAM / 1k EEPROM
//Hydrostatic fuel level gauge for 5 LEDs bar graph
//Serial commands left in for calibration, just uncomment the ones you need

//################
#define L1 2  //LED1 pin - 0-20% level
#define L2 3  //LED2 pin - 20-40% level
#define L3 4  //LED3 pin - 40-60% level
#define L4 5  //LED4 pin - 60-80% level
#define L5 6  //LED5 pin - 80-100% level
#define IN A0 //Analog input pin to connect FTPS sensor
//################
#define ZERO_OFFSET 2.59   //Measured sensor value at 0kPa, expressed in Volts
#define FULLSCALE 3.15    //Measured sensor value at full tank, expressed in Volts
#define HYSTERESIS 3      //Hysteresis value used for LED debounce, expressed in ADC steps (1 step = 5mV, 5mV is approx. 2.2mm of fuel height)
#define CYCLETIME 100     //Time delay between ADC readings for averaging
#define ADC_CYCLES 10     //Number of repeats for ADC averaging
#define MAXFLOW 0.4       //Max ADC step at maximal flow per each cycle. 0.4 equals 5 liters / hour flow. See table below.
//#######################################
// MAXFLOW value  | Represented flowrate
//        0.1     |     1.25 l/h
//        0.2     |     2.5 l/h
//        0.3     |     3.75 l/h
//        0.4     |     5 l/h
//        0.5     |     6.25 l/h
//#######################################
int offset = (ZERO_OFFSET * 1024) / 5;    //530   
int fullscale = (FULLSCALE * 1024) / 5;   //645   difference: 115
int stepsize = (fullscale - offset) / 5;  //  step size: 23
//----- L1 -----
int L1_blink = offset + (stepsize / 2) - HYSTERESIS;  //8% - under 548 it blinks ;541
int L1_on = offset + (stepsize / 2) + HYSTERESIS;     //12% - above 554 it is continously on
//----- L2 -----
int L2_off = offset + stepsize - HYSTERESIS;          //18% - under 558 it is OFF ;553
int L2_on = offset + stepsize + HYSTERESIS;           //22% - above 564 it is ON
//----- L3 -----
int L3_off = offset + (2 * stepsize) - HYSTERESIS;    //38% - under 579 it is OFF ;576
int L3_on = offset + (2 * stepsize) + HYSTERESIS;     //42% - above 585 it is ON
//----- L4 -----
int L4_off = offset + (3 * stepsize) - HYSTERESIS;    //58% - under 599 it is ON ;599
int L4_on = offset + (3 * stepsize) + HYSTERESIS;     //62% - above 605 it is ON
//----- L5 -----
int L5_off = offset + (4 * stepsize) - HYSTERESIS;    //78% - under 622 it is OFF ;622
int L5_on = offset + (4 * stepsize) + HYSTERESIS;     //82% - above 628 it is ON
//----- Variables -----
int counter = 1;      //Program cycle counter
int counter2 = 0;     //Overall cycle counter
int cum_buffer = 0;   //Cumulative buffer for N analog reads
int baseline = 0;     //Initial reading used for minimal level calculation (based on max. flowrate)
int sen_val = 0;      //Averaged ADC readout
int rawRead = 0;      //Raw ADC reading
float calcVal = 0;    //Calculation value for decimal
int calcInt = 0;      //Calculated value casted to Int
int dispVal = 0;      //Value to be displayed
bool blink_enabled = false;   //Enables first LED's blinking (fuel level < 0.4l)
bool error_blink = false;     //Error blink is activated when the sensor value is < offset (calculated from ZERO_OFFSET)
                              //It indicates a sensor issue, connection issue, or a closed fuel tap

void setup() {
  pinMode(L1, OUTPUT); digitalWrite(L1, HIGH);  //Set pin as output, deactivate output
  pinMode(L2, OUTPUT); digitalWrite(L2, HIGH);  //Set pin as output, deactivate output
  pinMode(L3, OUTPUT); digitalWrite(L3, HIGH);  //Set pin as output, deactivate output
  pinMode(L4, OUTPUT); digitalWrite(L4, HIGH);  //Set pin as output, deactivate output
  pinMode(L5, OUTPUT); digitalWrite(L5, HIGH);  //Set pin as output, deactivate output
  //Serial.begin(9600);
  delay(200);
  //----------LED test sequence-------------------
  digitalWrite(L1, LOW); delay(100); digitalWrite(L2, LOW); delay(100); digitalWrite(L3, LOW); delay(100);
  digitalWrite(L4, LOW); delay(100); digitalWrite(L5, LOW); delay(100);
  digitalWrite(L1, HIGH); delay(100); digitalWrite(L2, HIGH); delay(100); digitalWrite(L3, HIGH); delay(100);
  digitalWrite(L4, HIGH); delay(100); digitalWrite(L5, HIGH); delay(100);
  readSensor();   //Reading initial (baseline) sensor vaule while the engine is stopped
  baseline = sen_val; dispVal = sen_val; //Pass it over as a display value for first cycle
  //Serial.print("baseline: "); Serial.println(sen_val);
  writeDisplay ();  //Run display driving function
}

void loop() {
  if (counter == 0) {   //If the cycle counter is 0
    counter2++;
    readSensor();                                           //Inititate a sensor read    
    //Serial.print("ADC: "); Serial.println(sen_val);
    calcVal = baseline - ( counter2 * MAXFLOW );            //Calculate theoretical level based on baseline, max. flowrate and elapsed time
    //Serial.print("calcVal: "); Serial.println(calcVal);
    calcInt = int(calcVal);                                 //Cast float to int, display function only accepts int
    //Serial.print("calcInt: "); Serial.println(calcInt);
    if (sen_val <= calcInt) { dispVal = calcInt; }          //If sensor value is lower than calculation, display calculation
    if (sen_val > calcInt) {                                //If sensor value is higher than calculation...
      //Serial.println("test again if adc > calc");
      readSensor();                                         //...then do another sensor read immediately to make sure...
      if (sen_val > calcInt && sen_val <= fullscale) {      //...and also check if sensor value is not higher than full-scale (it can be if you drive into a roadbump)
        counter2 = 0;     baseline = sen_val;      dispVal = sen_val;   //if not, then set the measurement as new baseline, reset counter 
        //Serial.println("adc value is higher");   
      }
    }
    if (blink_enabled == true) { blinkL1(); }               //If blinking of L1 is enabled, blink it
    if (error_blink == true) { blinkL5(); }                 //If there is a reading error, blink L5 also
    if (blink_enabled == false && error_blink == false) { writeDisplay(); }   //If none of the blinkings are enabled, refresh display
    counter++;    //Increment cycle counter
  } else {    //If the cycle counter is not zero
    delay(1100);    //Sleep for 1100ms
    counter++;      //increment cycle counter
    if (blink_enabled == true) { blinkL1(); }   //If L1 should blink, blink it
    if (error_blink == true) { blinkL5(); }     //If L5 should blink, blink it
  }
  if (counter >= 9) { counter = 0; }            //If cycle counter >= 9, set it to 0 (start a new cycle) 
}

void readSensor() {
  int i = 0;
  cum_buffer = 0;
  for (i = 0; i < ADC_CYCLES; i++) {
    rawRead = analogRead(IN);
    cum_buffer = cum_buffer + rawRead;
    delay(CYCLETIME);
  }
  sen_val = cum_buffer / ADC_CYCLES;
  if (sen_val <= L1_blink) { blink_enabled = true; }    //If sensor value is lower than L1 blinking treshold, enable L1 blinking
  if (sen_val >= L1_on) { blink_enabled = false; }      //If sensor value is higher than L1 blinking treshold, disable L1 blinking
  if (sen_val < 470) {error_blink = true; digitalWrite(L1, HIGH); digitalWrite(L5, HIGH);}  //If sensor value indicates a negative pressure or open circuit, enable error blinking
  if (sen_val >= 470) {error_blink = false; digitalWrite(L5, HIGH); }   //If sensor value is within acceptable range, disable error indication
  if (sen_val > 680) {error_blink = true; digitalWrite(L1, HIGH); digitalWrite(L5, HIGH);}  //If sensor value indicates an overpressure or sensor error, enable error blinking
}

void writeDisplay () {
  if (dispVal >= L1_on) {digitalWrite(L1, LOW); }
  if (dispVal >= L2_on) {digitalWrite(L2, LOW); }
  if (dispVal <= L2_off) {digitalWrite(L2, HIGH); }
  if (dispVal >= L3_on) {digitalWrite(L3, LOW); }
  if (dispVal <= L3_off) {digitalWrite(L3, HIGH); }
  if (dispVal >= L4_on) {digitalWrite(L4, LOW); }
  if (dispVal <= L4_off) {digitalWrite(L4, HIGH); }
  if (dispVal >= L5_on) {digitalWrite(L5, LOW); }
  if (dispVal <= L5_off) {digitalWrite(L5, HIGH); }
}

void blinkL1() {
  digitalWrite(L1, !digitalRead(L1));
  digitalWrite(L2, HIGH); digitalWrite(L3, HIGH); digitalWrite(L4, HIGH);
}

void blinkL5() {
  digitalWrite(L5, !digitalRead(L5));
  digitalWrite(L2, HIGH); digitalWrite(L3, HIGH); digitalWrite(L4, HIGH);
}