# Visually show beam in processing

**URL:** https://discourse.processing.org/t/visually-show-beam-in-processing/15979
**Category:** Project Guidance
**Created:** [November 30, 2019, 12:14pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979 "2019-11-30T12:14:42Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![shariqqureshi](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shariqqureshi](https://discourse.processing.org/u/shariqqureshi)
#### Post date: [November 30, 2019, 12:14pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/1 "2019-11-30T12:14:42Z")

</div>

in our final year project our wants us to show beam in processing software… i.e if we apply load on he beam in reality it will be visible in processing software also show us deformation recorded by strain guages …  
can we do this in processing software ??? ???

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [November 30, 2019, 1:02pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/2 "2019-11-30T13:02:42Z")

</div>

Absolutely you can!

- The Arduino can collect data from sensors  
Using A/D:  
[analogRead() - Arduino Reference](https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/)
- The Arduino and Processing can communicate.  
[Serial / Libraries / Processing.org](https://processing.org/reference/libraries/serial/index.html)  
[Serial - Arduino Reference](https://www.arduino.cc/reference/en/language/functions/communication/serial/)
- Processing can visualize that data  
[https://processing.org/](https://processing.org/)

Related post:

> [@Getting data from strain guages](https://discourse.processing.org/t/getting-data-from-strain-guages/15978):
>
> hello guys… i am facing problem regarding processing 3… we are doing final year project in which we are doing structural health monitoring by using strain guages. now being a civil engineer i am not capable of writing code in processing software to get data from ardunio with which strainguages are attached. can u people help me to write code to recieve data from dtrain guages…

Starting doing some exploration.  
There are lots of resources out there including this forum.

I may assist once you start doing some personal exploration on the subject.

🙂

---

<div class="post-metadata">

### Author: ![shariqqureshi](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shariqqureshi](https://discourse.processing.org/u/shariqqureshi)
#### Post date: [November 30, 2019, 1:07pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/3 "2019-11-30T13:07:11Z")

</div>

we are doing final year project in which we are doing structural health monitoring by using strain guages. now being a civil engineer i am not capable of writing code in processing software to get data from ardunio with which strainguages are attached.  
can u people help me to write code to recieve data from dtrain guages…

we will upload code of strain guage from arduino software to arduino chip and then want to receive output in processing software…  
first of all we are doing it on small sacel using strain guage bf350 strain guage attached with steel rule… after gettting results…  
then we wil perform it on large scale on real bridges…  
so we need code of processing software to get data from these strain guages…  
being a civil engineering student i am not familiar with java language… (coding)…  
how could i start ???

---

<div class="post-metadata">

### Author: ![shariqqureshi](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shariqqureshi](https://discourse.processing.org/u/shariqqureshi)
#### Post date: [November 30, 2019, 1:12pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/5 "2019-11-30T13:12:50Z")

</div>

did u understood m problem\>?

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [November 30, 2019, 1:18pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/6 "2019-11-30T13:18:29Z")

</div>

Yes.

There are lots of resources out there and you need to take this one step at a time.

Start with Processing tutorials here:

> **[Welcome to Processing!](https://processing.org/)**
>
> Processing is a flexible software sketchbook and a language for learning how to code. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology…

> **[The Coding Train](https://www.youtube.com/user/shiffman/playlists?view=50&sort=dd&shelf_id=2)**
>
> All aboard! The Coding Train is on its way with creative coding video tutorials on subjects ranging from the basics of programming languages like JavaScript to algorithmic art, machine learning, simulation, generative poetry, and more. Choo choo!

I will not be providing code for your academic project.  
I may assist once you start writing code and need assistance.

🙂

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [November 30, 2019, 1:20pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/7 "2019-11-30T13:20:17Z")

</div>

> [@shariqqureshi](#):
>
> how could i start ???

actually the problem is if you can not code processing you also can not code arduino…  
because what my idea was to ask you if you can show  
what the arduino is sending now  
by run arduino IDE, use the monitor tool  
and copy the lines the arduino is sending  
here to the forum post.

when we see that lines we can give help what processing code to use.

also you need to give more ideas what you want to do with the (string ) lines  
arduino sends.  
because just for a datalogging like put the data to a file  
you not need processing but can do too.

* * *

a graphic representation of a beam bending  
would be nice show for classroom, but  
would not fit to the bridge data collect???

* * *

a basic arduino processing intro i did [here](http://kll.engineering-news.org/kllfusion01/articles.php?article_id=92#example3)

---

<div class="post-metadata">

### Author: ![shariqqureshi](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shariqqureshi](https://discourse.processing.org/u/shariqqureshi)
#### Post date: [November 30, 2019, 1:22pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/8 "2019-11-30T13:22:44Z")

</div>

i am learning java language from youtube… but tommorow is our meeting and i have to show code… can u write a simple code of bf350 just to represent some data in tommorow’s meeting… further i m working on developing my skills in java i.e in processing by watching tutorials…

---

<div class="post-metadata">

### Author: ![shariqqureshi](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shariqqureshi](https://discourse.processing.org/u/shariqqureshi)
#### Post date: [November 30, 2019, 1:33pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/9 "2019-11-30T13:33:21Z")

</div>

[![](https://img.youtube.com/vi/t8WPlTSE5-4/maxresdefault.jpg "Arduino návody | Tenzometr BF350-3AA") ](https://www.youtube.com/watch?v=t8WPlTSE5-4)

this is what we are doing tommorow … i want code in processing…

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [November 30, 2019, 1:37pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/10 "2019-11-30T13:37:29Z")

</div>

so you read A0 and print to USB port.

if you send all that nice long string line to processing  
have a heavy job to use it.  
just the raw number would be better

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [November 30, 2019, 1:40pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/11 "2019-11-30T13:40:28Z")

</div>

> [@shariqqureshi](#):
>
> but tommorow is our meeting and i have to show code

> [@shariqqureshi](#):
>
> this is what we are doing tommorow … i want code in processing…

I had a student come to me for help last year.

He had a working project after 2 months of work and was collecting data from sensors using Arduino and displaying on Arduino IDE monitor and plotter.

In the last 3 weeks of his project he came to me and asked how he can visualize the data; I suggested Processing.

I got him started and he learned to program with Processing independently and came to me for assistance and guidance as required.

I did not give him a single line of code; I did assist him with his code when he was stuck and guided him.

He did all the work.

This is your project.

I will not provide you with code.

🙂

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [November 30, 2019, 2:36pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/12 "2019-11-30T14:36:08Z")

</div>

but i will show you something,  
that is not the arduino processing connection,  
as i link already to my tutorial,  
but possibly that is a good moment for a processing teaser

```auto
//https://discourse.processing.org/t/visually-show-beam-in-processing/15979/9
// v02

FloatList qs = new FloatList();
int beamlong = 300;
float q;

void setup() {
  size(400, 200);
  println("Cantilever beam with uniformly distributed load\nuse mouseY");
}

void draw() {
  background(200, 200, 0);
  get_force(); // ___________________________________ for now only mouseY / later USB Arduino loadcells
  draw_beam(); // ___________________________________ show a bending beam ( as line by points )
  time_plot(); // ___________________________________ draw a plot of the last 300 samples
}

void get_force() {
  q = map(mouseY, 0, height, 0.0, 1.0); // __________ operation mouseY for load
  qs.append(q); // __________________________________ remember on a array
  if ( qs.size() > beamlong ) qs.remove(0); // ______ delete oldest as we use short plot only  
  text( nf(q*100.0, 0, 1)+"%", width-50, 30); // ____ show in PCT too
}

void draw_beam() {
  fill(0);
  noStroke();
  rect(0, 0, 20, height); // ________________________ wall left / beam fix point
  stroke(0, 200, 0);
  strokeWeight(10); 
  for ( int i = 0; i < beamlong; i++) point( 20 + i, height/2 -w(i, beamlong, q));
}

void time_plot() {
  float zoom =30;
  push();
  stroke(200, 0, 0);
  strokeWeight(1);
  for ( int i = 0; i < qs.size(); i++ ) line(20+i, height-3, 20+i, height-3-qs.get(i)*zoom);
  pop();
}

//https://en.wikipedia.org/wiki/Euler%E2%80%93Bernoulli_beam_theory
//Cantilever beam with uniformly distributed load
/*
 E is the elastic modulus and I is the second moment of area of the beam's cross-section
 L length
 w(x) = q * x**2 * ( 6 * L - 4 * L * x + x**2 ) / 24 * E * I
 */

float w(float x, float L, float q) {
  float E = 1e10, I = 1; 
  float wx = q * sq(x) * ( 6*L - 4 * L * sq(x) ) / ( 24 * E * I );
  return wx;
}

```

 ![bending_beam_mouseY](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1a648d9e1749ce8590cf820f59e6267c57fcdc16.png)

so you have a show ( without online data for now )

---

<div class="post-metadata">

### Author: ![shariqqureshi](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shariqqureshi](https://discourse.processing.org/u/shariqqureshi)
#### Post date: [November 30, 2019, 2:44pm UTC](https://discourse.processing.org/t/visually-show-beam-in-processing/15979/13 "2019-11-30T14:44:15Z")

</div>

thanks…
