Skip to main content

Posts

Showing posts from November, 2021

Latest Post

What is Industry 4.0?

  What is Industry 4.0 and what are some of the technologies that are driving it? Industry 4.0 is a term that refers to the fourth industrial revolution, which is characterized by the integration of digital technologies, such as artificial intelligence, cloud computing, big data, the internet of things, robotics, and 3D printing, into the manufacturing sector. Industry 4.0 aims to create smart factories that are more efficient, flexible, and responsive to customer needs and market changes. Some of the technologies that are enabling Industry 4.0 are: - Artificial intelligence (AI) : AI is the ability of machines to perform tasks that normally require human intelligence, such as reasoning, learning, decision-making, and problem-solving. AI can help optimize production processes, improve product quality, reduce costs, and enhance customer satisfaction. - Cloud computing: Cloud computing is delivering computing services, such as servers, storage, databases, software, and analytics, over t

Play a melody with a Piezo speaker

  Play a Melody using the tone() function This example shows how to use the  tone()  command to generate notes. It plays a little melody you may have heard before. Hardware Required Arduino board piezo buzzer or a speaker hook-up wires Making header file To make the pitches.h file, either click on the button just below the serial monitor icon and choose "New Tab", or use Ctrl+Shift+N. Then paste in the following code: /************************************************* * Public Constants *************************************************/ # define NOTE_B0 31 # define NOTE_C1 33 # define NOTE_CS1 35 # define NOTE_D1 37 # define NOTE_DS1 39 # define NOTE_E1 41 # define NOTE_F1 44 # define NOTE_FS1 46 # define NOTE_G1 49 # define NOTE_GS1 52 # define NOTE_A1 55 # define NOTE_AS1 58 # define NOTE_B1 62 # define NOTE_C2 65 # define NOTE_CS2 69 # define NOTE_D2 73 # define NOTE_DS2 78 # define NOTE_E2 82 # define NOTE_F2 87 # de

A three-key musical keyboard using force sensors and a piezo speaker

  Simple keyboard using the tone() function This example shows how to use the tone() command to generate different pitches depending on which sensor is pressed. Hardware Required Arduino Board 8 ohm speaker 3 force sensing resistors 3 10k ohm resistors 100 ohm resistor hook-up wires breadboard Circuit Diagram  Header file required The sketch uses an extra file, pitches.h. This file contains all the pitch values for typical notes. For example, NOTE_C4 is middle C. NOTE_FS4 is F sharp, and so forth. This note table was originally written by Brett Hagman, on whose work the tone() command was based. You may find it useful for whenever you want to make musical notes. To make the pitches.h file, either click on the button just below the serial monitor icon and choose "New Tab", or use Ctrl+Shift+N. Then paste in the following code: /************************************************* * Public Constants *************************************************/ # define NOTE_B0 31 #

Input Pullup Serial

  Input Pullup Serial This example demonstrates the use of INPUT_PULLUP with pinMode(). It monitors the state of a switch by establishing  serial communication  between your Arduino and your computer over USB. Additionally, when the input is HIGH, the onboard LED attached to pin 13 will turn on; when LOW, the LED will turn off. Hardware Required Arduino Board A momentary switch, button, or toggle switch breadboard hook-up wire Circuit Diagram Code void setup () {   //start serial connection   Serial . begin ( 9600 );   //configure pin 2 as an input and enable the internal pull-up resistor   pinMode ( 2 , INPUT_PULLUP);   pinMode ( 13 , OUTPUT); } void loop () {   //read the pushbutton value into a variable   int sensorVal = digitalRead ( 2 );   //print out the value of the pushbutton   Serial . println (sensorVal);   // Keep in mind the pull-up means the pushbutton's logic is inverted. It goes   // HIGH when it's open, and LOW when it's pressed. Turn on pin 13 when the  

Edge Detection

  State Change Detection (Edge Detection) for pushbuttons Once you've got a  pushbutton  working, you often want to do some action based on how many times the button is pushed. To do this, you need to know when the button changes state from off to on, and count how many times this change of state happens. This is called  state change detection  or  edge detection.  In this tutorial we learn how to check the state change, we send a message to the Serial Monitor with the relevant information and we count four state changes to turn on and off an LED. Hardware Required Arduino Board momentary button or switch 10k ohm resistor hook-up wires breadboard Circuit Diagram Code // this constant won't change: const int  buttonPin = 2 ;    // the pin that the pushbutton is attached to const int ledPin = 13 ;       // the pin that the LED is attached to // Variables will change: int buttonPushCounter = 0 ;   // counter for the number of button presses int buttonState = 0 ;        

Read a pushbutton, filtering noise

  Debounce Pushbuttons often generate spurious open/close transitions when pressed, due to mechanical and physical issues: these transitions may be read as multiple presses in a very short time fooling the program. This example demonstrates how to   debounce   an input, which means checking twice in a short period of time to make sure the pushbutton is definitely pressed. Without debouncing, pressing the button once may cause unpredictable results. This sketch uses the   millis()   function to keep track of the time passed since the button was pressed. Hardware Required Arduino Board momentary button or switch 10k ohm resistor hook-up wires breadboard Circuit Diagram Code // constants won't change. They're used here to set pin numbers: const int buttonPin = 2 ;    // the number of the pushbutton pin const int ledPin = 13 ;      // the number of the LED pin // Variables will change: int ledState = HIGH;         // the current state of the output pin int buttonState;