ad space

Programming Arduino with Johnny-Five in Proteus

Arduino Johnny Five LED blink in Proteus

If you're a fan of tinkering with electronics, chances are you've come across Arduino, the popular open-source hardware platform. Arduino is known for its versatility and ease of use, making it a popular choice for DIY projects, prototyping, and even professional applications. One powerful way to program an Arduino board is by using the Johnny-Five library, which brings the joy of JavaScript to hardware programming. 

This is a first part tutorial on Programming Arduino with Johnny-Five in Proteus. Here we will explain the libraries required, software, application for programming Arduino with Johnny-Five in Proteus.

What is Johnny-Five?

Johnny-Five is a JavaScript robotics and IoT platform that allows you to control various hardware boards, including Arduino, Raspberry Pi, and more, using JavaScript. Johnny-Five provides an easy-to-use, high-level API that abstracts the complexity of interacting with hardware, making it accessible to developers with little or no experience in embedded systems programming. With Johnny-Five, you can write JavaScript code to control sensors, actuators, motors, and other electronic components, and create interactive and responsive projects that can sense and react to the environment. 

But in order to install Johnny-Five library and run Johnny-Five library based javascript code we need Node.js.

What is Node.js?

Node.js is a JavaScript runtime environment that allows JavaScript code to run on the server-side of web applications. It is built on the V8 JavaScript engine, which is an open-source JavaScript engine developed by Google for use in the Google Chrome web browser.

Node.js provides an event-driven, non-blocking I/O model that makes it highly efficient and scalable for handling concurrent connections and processing requests asynchronously. It uses an event loop and a single-threaded event-driven architecture, which allows it to handle a large number of connections and requests without blocking the execution of other tasks.

One of the key features of Node.js is its ability to use JavaScript for both server-side and client-side development. This allows developers to use the same language, JavaScript, for both the front-end and back-end development, which can streamline the development process and make it easier to share code between the front-end and back-end of a web application.

Node.js has a large and active community of developers and a vast ecosystem of libraries and modules available through its package manager, npm (Node Package Manager), which makes it easy to extend its capabilities and build complex web applications. It is widely used for building scalable web applications, real-time applications, RESTful APIs, microservices, and more.

Overall, Node.js has gained significant popularity due to its performance, scalability, and versatility, making it a popular choice for server-side JavaScript development and enabling developers to build modern web applications with ease.

You can download and install Node.js from the following link:

https://nodejs.org/en

You can either install recommended or current version. But it is advisable to install the recommended one to avoid any problem.

nodejs

 After download just install it which is very easy.

Install Johnny-Five

Once you have installed node.js, create a new folder where you will be creating proteus projects with johnny-five. If you install in johnny-five in the default location where you installed node.js then you will need to install johnny-five in every new project folder. Here a new folder called johnnyfive is created. 

In the new folder, open terminal and then type in npm init

npm init

The npm init command is used to create a Node.js project. The npm init command will create a json package and a node_modules folder where the library files and dependencies will be stored.

npm init

Install Johnny-Five

Once you have installed Node.js, you will be able to install the Johnny-Five library. Johnny-Five is an npm package, so you can install it using Node.js, a popular JavaScript runtime environment. Open your terminal or command prompt and run the following command:

npm install johnny-five

This will install the Johnny-Five library, a new package-lock json file is created and library dependencies are downloaded within the node_modules folder.

johnnyfive

Firmata

The next step is to generate firmata hex file which has to be loaded into Arduino part in Proteus. The firmata program is required so that Arduino can communicate with devices such as PC. Firmata is a generic protocol for communicating with microcontrollers from software on a host computer. It is intended to work with any host computer software package.

Open Arduino IDE and open Firmataplus program from File>Eamples>Firmata>StandardFirmataPlus as shown below.
 
firmata

 Then compile this StandardFirmataPlus program. Then copy the location where the generated hex is stored. For this you need to change the preference and select show Verbose output during compilation and upload as illustrated below.


You can save the StandardFirmataPlus.ino.hex file in the Proteus project folder so that you can easily find it next time you need it.

What is Proteus?

Proteus is a popular electronic circuit simulation software that allows you to design, simulate, and test electronic circuits before building them in the real world. Proteus provides a wide range of components, including Arduino boards, sensors, actuators, and other electronic components, that you can use to create virtual electronic circuits and simulate their behavior. Proteus is widely used by hobbyists, students, and professionals for prototyping and testing electronic circuits without the need for physical components, making it a valuable tool for experimenting and learning.

Why use Johnny-Five in Proteus?

Using Johnny-Five in Proteus allows you to harness the power of JavaScript to program Arduino boards, and simulate their behavior in a virtual environment before deploying them in the real world. There are several advantages to using Johnny-Five in Proteus for your Arduino projects:

  • Familiar JavaScript syntax: If you're already familiar with JavaScript, using Johnny-Five in Proteus allows you to leverage your existing JavaScript skills to program Arduino boards, eliminating the need to learn a new programming language.
  • Rapid prototyping: Proteus provides a virtual environment where you can design and simulate electronic circuits, allowing you to quickly prototype and test your Arduino projects without the need for physical components. This can save you time and resources in the prototyping phase of your project.
  • Safe experimentation: Since Proteus is a virtual environment, you can experiment with different electronic components and circuit configurations without the risk of damaging physical components. This allows you to iterate and optimize your Arduino projects in a safe and controlled environment.
  • Interactive simulations: Proteus allows you to create interactive simulations of your Arduino projects, where you can observe the behavior of your circuits in real-time, and interact with sensors and actuators to see how they respond. This can be a powerful tool for debugging and fine-tuning your projects.
  • IoT Projects: Using Johnny-Five with Proteus for IoT(Internet of Things) enables developers to prototype and test Arduino-based IoT applications, IoT monitoring and IoT monitoring solutions testing in a virtual environment. It provides a convenient and efficient way to develop, debug, and simulate hardware interactions using JavaScript, making it easier to build and deploy IoT solutions.

Install Proteus

To get started, you'll need to install Proteus on your computer. Proteus is a commercial software, but it offers a free trial version with limited features that you can use for learning and experimentation. You can download Proteus from the official Proteus website and follow the installation instructions.

The next part of this tutorial Getting Started with Johnny-Five in Proteus will guide step by step how you can program Arduino with Johnny-Five in Proteus.

References and Further Readings

[1] Interfacing Proteus and MATLAB-SIMULINK for Co-Simulation

[2] Send data from Simulink to Proteus for Arduino Co-Simulation

[3] Arduino in Proteus co-simulation with Simulink: Advantages & Applications

Post a Comment

Previous Post Next Post