# Why can I not draw in the serialEvent() function?

**URL:** <https://discourse.processing.org/t/why-can-i-not-draw-in-the-serialevent-function/18032>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [February 22, 2020, 11:59pm UTC](https://discourse.processing.org/t/why-can-i-not-draw-in-the-serialevent-function/18032 "2020-02-22T23:59:35Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [February 23, 2020, 2:25pm UTC](https://discourse.processing.org/t/why-can-i-not-draw-in-the-serialevent-function/18032/5 "2020-02-23T14:25:32Z")

</div>

Alternatively, if you just need to refresh the canvas when new data arrives, you can use the **noLoop()** / **redraw()** technique: 💡

> [@Map function worked in Processing 2 and early 3.. But broke in 3.5.3. Need guidance](https://discourse.processing.org/t/map-function-worked-in-processing-2-and-early-3-but-broke-in-3-5-3-need-guidance/11371/2):
>
> Mutating the sketch’s main canvas outside the “Animation Thread” crashes the program! boomCallback serialEvent() is run by the Serial’s Thread btW. warningSo even calling something like background() can be fatal! fearfulActually, due to a bad design, any Processing function which depends on color() will get wrong results when they’re multithreading invoked! bugSo any canvas mutating operations should be moved to draw() or called by it. face_with_monocleHere’s a post link for…

---

_[View the full topic](https://discourse.processing.org/t/why-can-i-not-draw-in-the-serialevent-function/18032)._
