Practical Arduino Cool Projects for Open Source Hardware- P16

Practical Arduino Cool Projects for Open Source Hardware- P16: A schematic or circuit diagram is a diagram that describes the interconnections in an electrical or electronic device. In the projects presented in Practical Arduino, we’ve taken the approach of providing both a photograph and/or line drawing of the completed device along with a schematic. While learning to read schematics takes a modest investment of your time, it will prove useful time and time again as you develop your projects. With that in mind, we present a quick how-to in this section | CHAPTER 8 TOUCH CONTROL PANEL coordinates to control a 3D cube visualization. Processing is the sister project to Arduino while Arduino is all about controlling physical events Processing is all about visualization image processing and representing events graphically. In fact the Arduino IDE is based on the Processing IDE so if you re familiar with one you ll feel right at home with the other. To run the 3D cube program you ll need to download the latest version of Processing from and install it on your computer. You can then download the sketch called TouchCube from the project page on the Practical Arduino web site. Processing programs follow a very similar structure to Arduino programs. They have a setup function at the start that is called first just as in Arduino but rather than having a main program loop called loop it s called draw in Processing. The first thing the TouchCube program does is include the serial port class and create an instance called myPort. import . Serial myPort Then we set up variables for storing values from the Arduino and the current camera position. int touchX The X coordinate value received from the serial port int touchY The Y coordinate value received from the serial port float xPos 512 Current camera X-axis position float yPos 512 Current camera Y-axis position The setup function determines how big the window should be for the visualization using the size function sets the background fill color and then opens the serial port to wait for values sent by the Arduino. One critical part of this setup function is the line right at the end that tells the serial port object to buffer store all values it receives until it gets a newline. We ll get back to that in just a moment. void setup size 800 600 P3D fill 204 104 0 myPort new Serial this 0 38400 n The main program loop called draw doesn t need to do anything in this case because everything is done in an event handler.

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.