Questions
There is something wrong with my arduino lab. I want my four leds to light up...

There is something wrong with my arduino lab. I want my four leds to light up one after the other. Then the speaker plays music, and 4 leds change with music. But my code only makes one of them work. Please help me modify my code

const int switchPin = 8; unsigned long previousTime = 0; int switchState = 0; int prevSwitchState = 0; int led = 2; // 600000 = 10 minutes in milliseconds long interval = 1000; int tonepin=9; int bpm = 120; int song[100][2] = { {AA3,Q},{AA3,Q},{AA3,Q},{F3,E+S},{C4,S},{AA3,Q},{F3,E+S},{C4,S},{AA3,H}, {E4,Q},{E4,Q},{E4,Q},{F4,E+S},{C4,S},{Ab3,Q},{F3,E+S},{C4,S},{AA3,H}, {AA4,Q},{AA3,E+S},{AA3,S},{AA4,Q},{Ab4,E+S},{G4,S}, {Gb4,S},{E4,S},{F4,E},{R,E},{Bb3,E},{Eb4,Q},{D4,E+S},{Db4,S}, {C4,S},{B3,S},{C4,E},{R,E},{F3,E},{Ab3,Q},{F3,E+S},{AA3,S}, {C4,Q},{AA3,E+S},{C4,S},{E4,H},{AA4,Q},{AA3,E+S},{AA3,S},{AA4,Q},{Ab4,E+S},{G4,S}, {Gb4,S},{E4,S},{F4,E},{R,E},{Bb3,E},{Eb4,Q},{D4,E+S},{Db4,S}, {C4,S},{B3,S},{C4,E},{R,E},{F3,E},{Ab3,Q},{F3,E+S},{C4,S}, {AA3,Q},{F3,E+S},{C4,S},{AA3,H} }; int num_notes = 70; int led_notes[] = {Ab3,AA3,F3,C4,E4,F4,Gb4,G4}; int num_leds = 8 ; int leds[] = {4,5,6,7} ; void setup() { for (int x = 4; x < 8; x++) { pinMode(x, OUTPUT); } pinMode(switchPin, INPUT); } void servo(){ myServo.attach(9); Serial.begin(9600); } void led_on_v3() { pinMode(tonepin, OUTPUT); for (int i=0; i < (num_leds-1); i++) { pinMode(leds[i], OUTPUT); } } void leds_on(int note) { for (int i=0; i < (num_leds-1); i++) { if (led_notes[i] == note) { digitalWrite(leds[i],HIGH); } } } void leds_on_v2(int note) { for (int i=0; i < (num_leds-1); i++) { if (led_notes[i] == note) { digitalWrite(leds[i],HIGH); } else { digitalWrite(leds[i],LOW); } } } void leds_off() { for (int i=0; i < (num_leds-1); i++) { digitalWrite(leds[i],LOW); } } void play_note(int note, long duration) { int blink_lights = 1; if (blink_lights == 1) { leds_on_v2(note); } if (note != R) { tone(tonepin, note, duration); delay(duration); delay(1); } } void play_song(int which_song) { for (int i=0; i < num_notes; i++) { play_note(song[i][0], song[i][1]); } } void loop() { // store the time since the Arduino started running in a variable unsigned long currentTime = millis(); // compare the current time to the previous time an LED turned on // if it is greater than your interval, run the if statement if (currentTime - previousTime > interval) { // save the current time as the last time you changed an LED previousTime = currentTime; // Turn the LED on digitalWrite(led, HIGH); // increment the led variable // in 10 minutes the next LED will light up led++; if (led == 7) { } } switchState = digitalRead(switchPin); if (switchState != prevSwitchState) { for (int x = 4; x < 8; x++) { digitalWrite(x, LOW); } led = 2; previousTime = currentTime; prevSwitchState = switchState; } prevSwitchState = switchState; play_song(0); delay(1000); }


In: Electrical Engineering

In order to test the functionality of a piezo sensor, we simply connect a LED with...

In order to test the functionality of a piezo sensor, we simply connect a LED with a resistance to the piezoelectric sensor. a. (5 pts) Could the LED work if we put pressure to the sensor? b. (10 pts) what is the element that we have to add to make sure that the LED will provide light ? why , justify ? Can I use Aurduino Uno IN PART b? The rectifier circuit isn't covered in my course yet. thanks

In: Electrical Engineering

Design and discuss four bit BCD adder. Differentiate it from parallel adder          

Design and discuss four bit BCD adder. Differentiate it from parallel adder          

In: Electrical Engineering

i want to take a 12vac input voltage and convert it to 20vdc , 12vdc+, 12vdc-,...

i want to take a 12vac input voltage and convert it to 20vdc , 12vdc+, 12vdc-, 5vdc+

How can i do that using a full bridge rectifier, zener diodes, diodes, capacitors. Cannot use a voltage rectifier chip.

In: Electrical Engineering

Q.1 A parallel plate transmission line has plate separation d = 1 cm, and filled with...

Q.1 A parallel plate transmission line has plate separation d = 1 cm, and filled with teflon having dielectric constant εr = 2.1.

  1. Determine the maximum operating frequency such only the TEM mode will propagate.
  2. If the operating wavelength is λ = 3 mm. Find how many waves modes will propagate.
  3. If the operating frequency is 30 GHz, mode m = 1 and m = 2 will be above cutoff. Determine the group delay difference between these two modes over a distance of 1 cm.

In: Electrical Engineering

a. Using Matlab scripts create the following matrices (???1 and ???2) ???1 = [ 3 2...

a. Using Matlab scripts create the following matrices (???1 and ???2)

???1 = [
3 2 −3 6 7 4 3 −6 7
], ???2 = [
2 1 7 3 3 9 −6 6 1
]   

b. Write code to add the second row of ???1 to the third row of ???2 and store results in the first row of ???1.

c. Write code to add the second column of ???1 with the third column of ???2 and store results in the first column of ???2

In: Electrical Engineering

In Verilog, implement a circuit capable of adding and subtracting 8-bit binary numbers. You should submit...

In Verilog, implement a circuit capable of adding and subtracting 8-bit binary numbers. You should submit a single Verilog file that contains all of the necessary modules and also contain a module named top(A, B, sel, F, C).

For the selection, use a 0 to select Addition and a 1 to select Subtraction.

In: Electrical Engineering

A synchronous generator has parameters as shown in table below. 1. Voltage Rating 30 kV, 3-phase...

A synchronous generator has parameters as shown in table below.

1.

Voltage Rating

30 kV, 3-phase

5.

Frequency

50 Hz

2.

Power Rating

50 MVA

6.

Rotor

Round

3.

Synchronous Reactance,

XS

7 Ω /phase

7.

Connection

STAR

4.

Armature resistance, Ra

1.5 Ω /phase

8.

Excitation Type

Permanent Magnet

  1. An inductive load of 30MW at 0.8 power factor at rated terminal voltage is connected to the synchronous generator to an infinite bus. Determine the excitation voltage per phase and its corresponding power angle. Sketch a phasor diagram for this condition.?
  2. With reference to (a), without losing synchronism, what will be the maximum power the generator will be
    able to deliver? Also, determine the armature current at this condition.?
  3. Turbine torque is reduced until generator output is 15MW while excitation is held constant as in (a) above,
    determine the power angle, armature current, and power factor.?
  4. If now the load has changed to a rated power at rated voltage load, with a leading power factor of 0.8,
    determine the percentage voltage regulation of this generator.?

In: Electrical Engineering

Describe the E multiplexing system and compare it to the T system

Describe the E multiplexing system and compare it to the T system

In: Electrical Engineering

A circuit has a 2.9 V battery connected in series with a switch. When the switch...

A circuit has a 2.9 V battery connected in series with a switch. When the switch is closed, the battery powers two paths in parallel, one of which has a resistor of resistance R1 = 80 Ω in series with an inductor of inductance L = 1×10−2 H , while the other has a resistor of resistance R2 = 230 Ω . What is the current supplied by the battery at a time t = 0.25 ms after the switch is closed? What is the current i1 supplied by the battery a time t = 0.25 ms after the switch is closed? Express your answer in amperes to three significant figures.

In: Electrical Engineering

(Please just show the design of the circuit) A printed circuit board manufacturing laboratory needs to...

(Please just show the design of the circuit) 
A printed circuit board manufacturing laboratory needs to have controlled environmental conditions, such as temperature, pressure, and humidity. These variables are measured by means of sensors that deliver an electrical signal which must be conditioned before being sent to a microcontroller for processing.

The challenge is to perform signal conditioning with pressure sensor op amps with part number MPX4250. The conditions that this signal conditioning must meet are the following:

Required work interval:

Pressure 75 to 105 kPa ---> Average conditions for Mexico
Output voltage 0 to 5V ---> With a margin of error of +/- 10%
The sensor signal can be simulated using a voltage source, if the component is not present in the simulation software. This signal conditioning will help the Vo output signal to be controlled by a microcontroller in a next stage of the complete environmental condition monitoring system.

In: Electrical Engineering

How can you match the following dividers to the LV measuring instruments (i) resistive divider (ii)...

How can you match the following dividers to the LV measuring instruments
(i) resistive divider (ii) capacitive divider, (iii) resistive-capacitive divider, and (iv) damped capacitive divider?

In: Electrical Engineering

Answer these questions and submit them before your lab session. Derive a relationship between the voltage...

Answer these questions and submit them before your lab session.

  1. Derive a relationship between the voltage amplitudes Vs, VR, VC, and VL for the RLC circuit. Hint: how is Vs related to the impedance?

  2. A series RLC circuit is driven at 500 Hz by a sine wave generator. It has parameters R = 5kΩ, L = 2H, and C = 2μF. What is the impedance of the circuit?

  3. What is the phase resonance frequency for the circuit in the previous question?

  4. Does this circuit have amplitude resonances? If so, what are their frequencies?

  5. If you use instead a 0.08 μF capacitor, does the circuit have amplitude resonances? If so, what are their frequencies? What is the new phase resonance?

Questions 3- 5 But im sure the info from question 1 and 2 is needed

In: Electrical Engineering

396 v, 60 Hz, 600 hp, 0.6 pf-leading, four-pole triangle connected synchronous motor has 0.9Ω synchronous...

396 v, 60 Hz, 600 hp, 0.6 pf-leading, four-pole triangle connected synchronous motor has 0.9Ω synchronous reactance. Friction; wind; core losses and armature resistance are neglected. a) If the motor is operating under magnitude of phase current (ia) 216 Ampere and power factor of 0.6 lagging, 1. Find the input power of motor in hp ( 2. Find the generated voltage, EA 3. Find the torque and the maximum inducible torque in current state. b) If EA is increased by 18% find, 1. Magnitude of new armature current (ia), ( 2. New power factor of motor. (Please use at least 4 digits after decimal point in your calculations. Otherwise, there may be problems about exact answers.)

In: Electrical Engineering

Given a balanced three-phase delta-connected generator with positive sequence and voltage Vbc=350∠−90∘Vbc=350∠−90∘ Vrms. The generator feeds...

Given a balanced three-phase delta-connected generator with positive sequence and voltage Vbc=350∠−90∘Vbc=350∠−90∘ Vrms. The generator feeds a balanced three-phase delta-connected load having an impedance of 43.5+j27 Ω/phase. The impedance of the line connecting the generator to the load is 1.5+j1 Ω/phase.  i) Calculate the total real power consumed by the load. [5] ii) Calculate the percentage of the total available real power lost in the lines.[3]

  

In: Electrical Engineering