Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:45:41+00:00 2026-06-12T18:45:41+00:00

I have written a test program to see that my pressure sensor is working

  • 0

I have written a test program to see that my pressure sensor is working correctly and it does.

int redpin = 10;
int greenpin = 9;
int bluepin = 8;
int presurepin = 0;

//Program variables
int time = 100;
int presure = 0;
int thresholddown = 19;
int thresholdup = 52;
int color = 0;
int red   = 0;
int green = 0;
int blue  = 0;
int relesepresure = 1;

void setup() {
  pinMode(redpin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // Read presure
  presure = analogRead(presurepin);

  // For bug finding purpose
  delay(time);
  Serial.print(presure);
  Serial.print("   ");
  Serial.println(color);

  // High presure = 0 low = 300-500
  // If high presure change color and wait until presure is low to send out the color
  if (presure < thresholddown && relesepresure == 1){
    if (color == 0){
          red   = 0;
          green = 0;
          blue  = 0;
          color = color + 1;
    }
    else if (color == 1) {
          red   = 1;
          green = 0;
          blue  = 0;
          color = color + 1;
    }
    else if (color == 2) {
          red   = 0;
          green = 1;
          blue  = 0;
          color = color + 1;
    }
    else if (color == 3) {
          red   = 0;
          green = 0;
          blue  = 1;
          color = color + 1;
    }
    else if (color == 4) {
          // Yellow
          red   = 1;
          green = 1;
          blue  = 0;
          color = 1;

    }
    // Turn of light while tile is presured
    digitalWrite(redpin,   0);   // Write current values to LED pins
    digitalWrite(greenpin, 0);
    digitalWrite(bluepin,  0);
    relesepresure = 0;
  }
  else if (presure > thresholdup && relesepresure == 0){
      //Send color to tile
      digitalWrite(redpin,   red);
      digitalWrite(greenpin, green);
      digitalWrite(bluepin,  blue);
      relesepresure = 1;
  }
}

So in this code above, what I want to do is to store all the times the functions write either red, green, blue, yellow, etc. and display it on a computer screen in real time bar graphs.
Something like Flot Examples but with bars.

So naturally I need to do somehing like this:

else if (color == 3) {

      //Color3++;
      //Update the bar graph with the new values (Color1,0),(Color2,1), (Color3,2), (Color4,3) where the numbers inside the paragraph are the x,y values of the graph.

      red   = 0;
      green = 0;
      blue  = 1;
      color = color + 1;
}

How can this be achieved since Arduino is a very limited language? I was thinking about writing these variable values to a simple .json file and read them from there with jQuery, but I don’t know how to do that either. Is there a smarter solution?

I’m using an Arduino Mega.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:45:43+00:00Added an answer on June 12, 2026 at 6:45 pm

    First, you are going to have something going between JQuery and the Arduino Mega. Some of your options are:

    • Access the arudino through a usb cable and use some sort of server based technology to access it, such as php. There is an example of how to do this here:

    http://wanderr.com/jay/controlling-arduino-via-serial-usb-php/2010/12/28/

    • Use an ethernet or wifi shield and provide the data back in the format of your choice. This would add about $30-60 to your cost but make the arduino part of this project self contained and not require a computer for it to run.

    • if you want it wireless you could look into bluetooth and zigbee recievers. you would still need a server and something like php with this option.

    • for flash, you typically use something called a serial socket server. There is more inforamation about this on the Aruduino Playground. It is possible you could also access the same type of server through jquery directly. This would be similar to the first option and would require a direct usb connection to the computer.

    If you wanted to try something different, I would recommend looking at processing and firmata as there are lots of examples of how take data from an arduino and create some sort of visual based on that data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a test program that I have written for a larger project that
I have written a function that sorts a big scale of data. To test
I have a test suite DLL written in C# that uses Selenium.This is then
I have written a very small C# program, that uses a very small SQL
I have written a program in .NET that listens to a particular Serial Port
I have written a small test program in which I try to use the
I have written a program that takes the filename from argv[1] and do operations
I have written a small Sample program to see about Eclipse Conditional Break Points
I've written a test program using OpenGL on OS X that loads a PNG,
I have written a test program to test out SCHED_FIFO . I have learnt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.