# From Processing to Arduino Stepper motor 28BYJ-48 with ULN2003

**URL:** <https://discourse.processing.org/t/from-processing-to-arduino-stepper-motor-28byj-48-with-uln2003/38804>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [September 16, 2022, 2:11pm UTC](https://discourse.processing.org/t/from-processing-to-arduino-stepper-motor-28byj-48-with-uln2003/38804 "2022-09-16T14:11:33Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [September 16, 2022, 10:25pm UTC](https://discourse.processing.org/t/from-processing-to-arduino-stepper-motor-28byj-48-with-uln2003/38804/4 "2022-09-16T22:25:39Z")

</div>

Hello,

- First get the stepper motor working independent of Processing.
- Consider how to send the same _control values_ from Processing to Arduino.
- Give consideration to timing and each loop on Processing and Arduino side.
- Get the serial communication working without the hardware.
- Integrate the serial with the hardware.
- Troubleshoot.

There are many ways to monitor the serial data you are sending; I provided a simple example that does not require additional hardware and only a few extra lines of code.

This will help you monitor the data you are sending and echo it back:

> **Processing Code \< Click here to open!**
>
> ```auto
> import processing.serial.*;
> import controlP5.*;
> ControlP5 cp5;
> Serial port;
> 
> int myColor = color(0, 0, 0);
> int sliderValue = 100;
> 
> int val, counter;
> 
> void setup() {
> size(500, 300);
> printArray(Serial.list());  
> // "COM5"
> port = new Serial(this, Serial.list()[4], 9600);
> delay(1000); // Give the Arduino a chance to reboot before sending data
> 
> cp5 = new ControlP5(this);
> ;
> // add a horizontal sliders, the value of this slider will be linked
> // to variable 'sliderValue' 
> cp5.addSlider("sliderValue")
> .setPosition(100, 50)
> .setRange(20, 200)
> ;
> }
> 
> void draw() 
> {
> if (frameCount%60 == 0) // Once a second
> {
> port.write(sliderValue);
> println("Tx: ", sliderValue);
> }
>   
> if(port.available() > 0)
> {
> val = port.read();
> println("Count: ", counter++);
> println("Rx: ", val);
> }
>   
> fill(sliderValue);
> rect(0, 0, width, 100);
> }
> 
> ```

> **Arduino Code \< Click here to open!**
>
> ```auto
> void setup() 
> {
> Serial.begin(9600);
> }
> 
> void loop() 
> {
> if (Serial.available()) 
> {
> int val = Serial.read();         
> Serial.write(val); // Echo back to Processing 
> }
> }
> 
> ```

References:  
[https://processing.org/tutorials/electronics](https://processing.org/tutorials/electronics)  
[https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all](https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/1/d/1ddfd70496897d5a1de9821834cb81afeb897459.png)

Once you grasp the serial communications between Processing and Arduino you can control anything.

Enjoy the journey!

`:)`

---

_[View the full topic](https://discourse.processing.org/t/from-processing-to-arduino-stepper-motor-28byj-48-with-uln2003/38804)._
