The code below is uded to interface arduino with a flame sensor and a gas sensor together: int redLed = 12; int greenLed = 13; int smokeA0 = A0; int flamePin = 11; int Flame = HIGH; int sensorThres=100; void setup() { pinMode(redLed, OUTPUT); pinMode(greenLed,OUTPUT); pinMode(flamePin, INPUT); pinMode(smokeA0,INPUT); Serial.begin(9600); } void loop() { int analogSensor = analogRead(smokeA0); Flame = digitalRead(flamePin); if (Flame== LOW) { Serial.println("Fire!!!"); digitalWrite(redLed, HIGH); } else { Serial.println("No worries"); digitalWrite(redLed, LOW); } Serial.print("Pin A0: "); Serial.println(analogSensor); // Checks if it has reached the threshold value if (analogSensor > sensorThres) { digitalWrite(greenLed, HIGH); } else { digitalWri...
Matlab Code:- clc; clear all; close all; x=input('Enter the sequence: '); N=length(x); Wn=exp((-j*2*pi)/N);%Twiddle factor fprintf('Twiddle Factor=%f+j(%f)\n',real(Wn),imag(Wn)); disp('Magnitude and phase of Twiddle Factor:'); fprintf('|Wn|=%f ',Wn); fprintf('angle Wn=%f\n', angle(Wn)); fprintf('\n'); for k=1:N X(k)=0; end %Calculation of DFT for k=1:N for n=1:N X(k)=X(k)+(x(n)*Wn^((k-1)*(n-1))); end end %Printing the DFT fprintf('DFT of x(n) is:\n'); disp(X); fprintf('\n'); fprintf('X(k)\tMagnitude\tPhase\n\n'); for k=1:N fprintf('X(%d)\t%f\t%f\n',k-1,X(k),angle(X(k))); end %To plot the magnitude and phase of the DFT subplot(1,2,1); stem(X,'linewidth',1.5); xlabel('k--->'); ylabel('magnitude--->'); title('Magnitude Response'); grid on; subplot(1,2,2); stem(angle(X),'linewidth',1.5); xlabel('k--->'); ylabel('...