Bitcoin Alert System

Hello World!

While i was working on assignment bitcoin alert system where buzzer turns on for 5 secs and turn of after, i built up a code :

image

but when i run the code my buzzer doesnt turn on (below) :

image

i have checked my circuit connections and buzzer works completely fine through bolt cloud api.

Here is my cryptocompare api output :

Any ideas of where i maybe going wrong?
Any help appreciated, thanks :slight_smile:

1 Like

Hi @h4heet,

  1. Your code never reaches to the if condition, because after return statement, It will exit from the get_bitcoin_price function and will never reaches to the conditional part.
    Remove the return current_price line from your code.

  2. You have only declared the get_bitcoin_price function but you have not called it any where.

  3. Only write the controlling part in the while loop.

Refer this Bitcoin extracting cost of it

Also instead of sharing screenshot of the code, share your code so that I can edit/fix your code.

Also for debugging the issue, use a print statement to check the flow of the program.

Do let me know in case you need any other help.

1 Like

brother your function is never called so the you will never retireve the bitcoin status so just assign the function to a value and compare them to activate the buzzer and set your selling price according to the values you see in the documentation provided in the task1.

Hi h4heet,
just call the function get_bitcoin_price() in the if loop and the time.time() in the second if loop does not increment the timer, so add the time.sleep(5), it will stop the response after 5 seconds., and since your dealing with while loop, be careful as it might, cross the message rate…

Hey @h4heet,
As you have written the conditions for checking the price under a user defined function, you need to call the function with appropriate parameters.In this case you need to call the get_bitcoin_price. Just call the function like get_bitcoin_price(selling_price). It should work now.
Cheers!

This way it is working

1 Like

bro even i wrote the same code but i am getting error
keyerror [“USD”]
error%20in%20buzzer
can you pleae help

check the url link properly…it should be ‘fsym’ not ‘fsyms’